x, = y (???)
Erik Max Francis
max at alcyone.com
Thu Jul 17 15:19:29 EDT 2008
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?
> 2. How could I have found this out on my own?
>
> (Regarding (2) above, I consulted the index of several Python
> reference books but I could not find the answer to (1). I hope to
> find a better Python reference!)
It's unpacking a 1-tuple:
(x,) = y
The parentheses here are not necessary and are sometimes left out.
--
Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
San Jose, CA, USA && 37 18 N 121 57 W && AIM, Y!M erikmaxfrancis
The United States, while they wish for war with no nation, will buy
peace with none. -- James Madison
More information about the Python-list
mailing list