meaning of: line, =

Rustom Mody rustompmody at gmail.com
Thu Feb 5 11:45:15 EST 2015


On Thursday, February 5, 2015 at 9:39:27 PM UTC+5:30, Ian wrote:
> On Thu, Feb 5, 2015 at 2:40 AM, Steven D'Aprano wrote:
> > Devin Jeanpierre wrote:
> >
> >> On Wed, Feb 4, 2015 at 1:18 PM, Chris Angelico wrote:
> >>> On Thu, Feb 5, 2015 at 4:36 AM, Peter Otten  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)?
> 
> >>> def f(a, (b, c)):
> ...     print a, b, c

What the hell is that?!
First I am hearing/seeing it.
Whats it called?



More information about the Python-list mailing list