News for hackers. Stuff that matters.
Re:Python idiom for taking the single item from a list by agentultra on Monday September 27, 2010 @01:45PM (#1732522)
Single-element tuple unpacking?

I've never found a case where I knew there would only be one element in a list, but I do use tuple unpacking all of the time.

Pretty cool I guess; didn't know it wasn't a common idiom. Good to know. Thanks for sharing. :)

Re:Python idiom for taking the single item from a list by marcinw on Monday September 27, 2010 @01:54PM (#1732570)
http://docs.python.org/library/struct.html#struct.unpack

"""The result is a tuple even if it contains exactly one item."""

I run into this constantly using struct.unpack(), and I find the author's idiom to be ideal way to handle this. I will use this from now on.