Re:Python idiom for taking the single item from a list
by statictype on Monday September 27, 2010 @08:57PM
(#1734182)
There's nothing wrong with `is l`. Sounds like you're just splitting hairs.
He's defending against None because calling __len__ on None results in an exception.
3.14159 also results in an exception but it's far more likely that the object passed was None than that it was a completely different type than the one expected.
Re:Python idiom for taking the single item from a list
by jemfinch on Tuesday September 28, 2010 @04:24PM
(#1737146)
> it's far more likely that the object passed was None than that it was a completely different type than the one expected.
FYI, None is a completely different type than the one expected.
I'm not sure why you'd defend against None anyway. Why defend against None, but not against 3.1459 or 4j or ''?