x, = y (???)
alif016 at gmail.com
Fri Jul 18 17:18:13 CEST 2008
> 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!)
>>> y = 'abc'
>>> y = y, # y, is just short for (y,) you *have* to use a coma in 1
>>> x, = y #same as x = y OR more verbosely (x,) = (y,)
Maybe that will hape you understand what the comma is for?
More information about the Python-list