A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2002-June/025460.html below:

[Python-Dev] behavior of inplace operations

[Python-Dev] behavior of inplace operationsJeremy Hylton jeremy@zope.com
Mon, 17 Jun 2002 08:40:30 -0400
>>>>> "DA" == David Abrahams <david.abrahams@rcn.com> writes:

  DA> I guess I am, even if I believed your "as-if" description:

  >>> a = range(12) 
  >>> t0,t1 = a,slice(2,9) 
  >>> t0[t1] = t0[t1] + [666]
  DA> Traceback (most recent call last):
  DA>   File "<stdin>", line 1, in ?
  DA> TypeError: sequence index must be integer

There seem to be many ways to spell this, all quite similar.  And
different versions of Python have different things to say about it.
Current CVS says:

   >>> a = range(12)
   >>> t0,t1 = a,slice(2, 9)
   >>> t0[t1] = t0[t1] + [666]
   Traceback (most recent call last):
     File "<stdin>", line 1, in ?
   ValueError: attempt to assign list of size 8 to extended slice of
   size 7

I suspect this is a bug, since I didn't ask for an extended slice.

   >>> a[2:9] = a[2:9] + [666]
   >>> a
   [0, 1, 2, 3, 4, 5, 6, 7, 8, 666, 9, 10, 11]

Jeremy





RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4