meaning of: line, =

Steven D'Aprano steve+comp.lang.python at pearwood.info
Thu Feb 5 04:40:53 EST 2015


Devin Jeanpierre wrote:

> On Wed, Feb 4, 2015 at 1:18 PM, Chris Angelico <rosuav at gmail.com> wrote:
>> On Thu, Feb 5, 2015 at 4:36 AM, Peter Otten <__peter__ at web.de> wrote:
>>> Another alternative is to put a list literal on the lefthand side:
>>>
>>>>>> def f(): yield 42
>>>
>>> ...
>>>>>> [result] = f()
>>>>>> result
>>> 42
>>
>> Huh, was not aware of that alternate syntax.
> 
> Nor are most people. Nor is Python, in some places -- it seems like
> people forgot about it when writing some bits of the grammar.

Got an example where you can use a,b but not [a,b] or (a,b)?




-- 
Steven




More information about the Python-list mailing list