python assignment

Juha Autero Juha.Autero at iki.fi
Wed Jul 23 04:28:22 EDT 2003


"Tim Peters" <tim.one at comcast.net> writes:

> It would be very unusual (because bad design) for the __iadd__
> method of a mutable type to return a pre-existing object, though.

I'm confused. I thought that the idea of __iadd__ is that for
*mutable* types it modifies existing object instead of returning new
one. So, was that a typo or are Python lists just bad desing:


>>> l=[]
>>> f=l
>>> f+=[1]
>>> f
[1]
>>> l
[1]

-- 
Juha Autero
http://www.iki.fi/jautero/
Eschew obscurity!






More information about the Python-list mailing list