x, = y (???)

kj socyl at 987jk.com.invalid
Thu Jul 17 21:55:59 CEST 2008


In <crydndTBLuLcBuLVnZ2dnUVZ_jWdnZ2d at speakeasy.net> Erik Max Francis <max at alcyone.com> writes:

>kj wrote:

>> I just came across an assignment of the form
>> 
>>   x, = y
>> 
>> where y is a string (in case it matters).
>> 
>> 1. What's the meaning of the comma in the LHS of the assignment?

>It's unpacking a 1-tuple:

>	(x,) = y

>The parentheses here are not necessary and are sometimes left out.

I still don't get it.  If we write 

  y  = 'Y'
  x, = y

what's the difference now between x and y?  And if there's no
difference, what's the point of performing such "unpacking"?

TIA!

kynn


-- 
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.



More information about the Python-list mailing list