Language design

Joshua Landau joshua at landau.ws
Thu Sep 12 00:17:44 EDT 2013


On 11 September 2013 11:38, Burak Arslan <burak.arslan at arskom.com.tr> wrote:
> On 09/10/13 09:09, Steven D'Aprano wrote:
>> What design mistakes, traps or gotchas do you think Python has?
>
> My favourite gotcha is this:
>
>     elt, = elts
>
> It's a nice and compact way to do both:
>
>     assert len(elts) == 0
>     elt = elts[0]
>
> but it sure looks strange at first sight. As a bonus, it works on any
> iterable, not just ones that support __getitem__.

I very much enjoy the "[elt] = elts" spelling, although I don't get
how this is a "gotcha". It's just a semi-obscure usage of unpacking.



More information about the Python-list mailing list