On Fri, Feb 6, 2015 at 12:12 PM, Devin Jeanpierre <jeanpierr...@gmail.com> wrote: > Here's another example, one that still exists in Python 3: > >>>> [] = '' >>>> () = '' > File "<stdin>", line 1 > SyntaxError: can't assign to () > > The syntax explicitly blacklists (), but forgets to blacklist [].
So... this is actually a really really obscure little feature. [] = x # is equivalent to try: next(iter(x)) except StopIteration: pass else: raise ValueError("too many values to unpack (expected 0)") It's a way of asserting that an iterator is exhausted! Perfect code snippet for your next International Obfuscated Python Code Contest entry. ChrisA -- https://mail.python.org/mailman/listinfo/python-list