Tuple assignment and generators?
Carl Banks
invalidemail at aerojockey.com
Fri May 5 00:25:32 EDT 2006
Larry Bates wrote:
> You must be careful with this as they all point to
> exactly the same object. Example:
>
> >>> q = r = s = t = u = v = 0
> >>> id(q)
> 3301924
> >>> id(r)
> 3301924
> >>> id(s)
> 3301924
But:
>>> q = 0
>>> r = 0
>>> s = 0
>>> id(q)
134536636
>>> id(r)
134536636
>>> id(s)
134536636
[snip]
> My rule, don't do it unless you know exactly why you
> want to do it. It will trip you up at some point and
> be VERY hard to find.
It's ok to do it with constant objects, really.
Carl Banks
More information about the Python-list
mailing list