[BangPypers] Nice "feature"

Shekhar Tiwatne pythonic at gmail.com
Fri Apr 1 15:31:45 CEST 2011


On Friday 01 April 2011 06:51 PM, Roshan Mathews wrote:
> On Fri, Apr 1, 2011 at 18:25, Navin Kabra<navin.kabra at gmail.com>  wrote:
>> With Python 2.6.5 (on ubuntu) I get even more bizarre behavior:
>>>>> foo=(1,[2,3,4])
>>>>> foo[1]+=6
foo[1]+6 won't work anyways
   l = [2,3,4]
   l+=6 # same error


foo[1] += [6] # treated as tuple operatation
foo[1].__add__([6]) # works, you know why :)
>> Traceback (most recent call last):
>>   File "<stdin>", line 1, in<module>
>> TypeError: 'int' object is not iterable
>>>>> foo
>> (1, [8, 9, 10])
>>
> Couldn't reproduce this.  Noufal's example "worked" though.
>
> Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit
> (Intel)] on win32
> and
> Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) on Ubuntu 10.04
>



More information about the BangPypers mailing list