Is there a commas-in-between idiom?

Georg Brandl g.brandl-nospam at gmx.net
Wed Nov 8 15:24:36 EST 2006


Peter van Kampen schrieb:
> On 2006-11-06, Fredrik Lundh <fredrik at pythonware.com> wrote:
>> I've collected a bunch of list pydioms and other notes here:
>>
>>     http://effbot.org/zone/python-list.htm
> 
> """
> A = B = [] # both names will point to the same list
> """
> 
> I've been bitten by this once or twice in the past, but I have always
> wondered what it was useful for? Can anybody enlighten me?

Do you never have a situation where you want to assign the same value
to two variables?

Or are you objecting to the fact that both names point to the same object?
It couldn't be otherwise. Consider:

X = []
A = B = X

What should this do? Copy "X" and assign one copy to A, one to B?

Georg



More information about the Python-list mailing list