what does 'a=b=c=[]' do
Thomas Rachel
nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915 at spamschutz.glglgl.de
Sat Dec 24 13:41:55 EST 2011
Am 22.12.2011 00:48 schrieb Steven D'Aprano:
> On Wed, 21 Dec 2011 18:20:16 -0500, Dennis Lee Bieber wrote:
>
>> For the amount of typing, it's easier to just do a straight line
>> tuple unpack
>>
>>>>> a,b,c = ([],[],[])
>
> Note that tuples are created by the comma, not the round brackets (or
> parentheses for any Americans reading). So the round brackets there are
> strictly redundant:
>
> a, b, c = [], [], []
>
> The only times you need the brackets around a tuple is to control the
> precedence of operations, or for an empty tuple.
IBTD:
a=((a, b) for a, b, c in some_iter)
b=[(1, c) for <whatever>]
Without the round brackets, it is a syntax error.
Thomas
More information about the Python-list
mailing list