x, = y (???)

Matthew Woodcraft mattheww at chiark.greenend.org.uk
Thu Jul 17 22:53:55 CEST 2008


kj wrote:
> 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"?

If y really is is a string, I think it's likely that the line you came
across was a typo.

In the case you give above, there's no difference at the end between x
and y.

If y had length other than 1, the second line would raise an exception,
so it's not the same as plain "x = y". But if that's the intended effect,
it's a daft way to write it.

-M-



More information about the Python-list mailing list