What's the value of "None" between 2.1.1 and 1.5.2
Steve Holden
sholden at holdenweb.com
Fri Nov 30 12:13:28 EST 2001
"Michael Abbott" <michael at rcp.co.uk> wrote ...
> "Steve Holden" <sholden at holdenweb.com> wrote :
>
> >> So why don't comparisons of this type generate an exception?
> >
> > Because comparisons are used in sorts, for example, and it wasn't
> > considered helpful for sorts of lists of arbitrary datatypes to raise
> > errors.
>
> Sigh. I understand.
>
> Of course, if you are sorting a list of arbitrary datatypes using random
> datatypes as the key then you're in a state of sin.
>
> I'm trying to figure out how to avoid this sinfulness (in general) in
> Python, but it's not easy!
Maybe. But for your existing simulation, where you seem to be using None to
record "No Value" (?) you can get away with
something = min([x for x in a if x])
List comprehensions were new in 2.0 (I think), and although they could be
faster in execution they are VERY cool for source code reduction.
regards
Steve
--
http://www.holdenweb.com/
More information about the Python-list
mailing list