On Thu, Sep 12, 2013 at 12:32 AM, Neil Cerutti <ne...@norwich.edu> wrote: > On 2013-09-11, Burak Arslan <burak.ars...@arskom.com.tr> wrote: >> My favourite gotcha is this: >> >> elt, = elts >> >> It's a nice and compact way to do both: >> >> assert len(elts) == 0 >> elt = elts[0] > > I'm confused. Your rewrite looks like an assertion error or an > IndexError.
Presumably he meant to assert that the length is 1. If elts is a list, then yes, these are equivalent, though the expanded form is actually a bit different (since any iterable can be used). ChrisA -- https://mail.python.org/mailman/listinfo/python-list