meaning of: line, =
Peter Otten
__peter__ at web.de
Wed Feb 4 12:36:48 EST 2015
Rustom Mody wrote:
> Well its cryptic and confusing (to me at least)
> And is helped by adding 2 characters:
>
> (result,) = f()
>
> instead of
>
> result, = f()
Another alternative is to put a list literal on the lefthand side:
>>> def f(): yield 42
...
>>> [result] = f()
>>> result
42
(If you're worried: neither the list nor the tuple will be created; the
bytecode is identical in both cases)
More information about the Python-list
mailing list