meaning of: line, =

Skip Montanaro skip.montanaro at gmail.com
Thu Feb 5 11:56:51 EST 2015


Tuple packing. No longer supported in Python 3, but in available in Python <= 2.

Skip


On Thu, Feb 5, 2015 at 10:45 AM, Rustom Mody <rustompmody at gmail.com> wrote:
> 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?
> --
> https://mail.python.org/mailman/listinfo/python-list



More information about the Python-list mailing list