>This is a perfect opportunity to give the reminder that the
>conversion 
>functions are also types that can be used more transparently for such

Neat I didn't know\ that. How dioes Python equate a function object
to a type? Is it hard wired?

> >>> [(type(x)==int and float(x) or x) for x in l]
>['foo', 0]
> >>> # notice that 0 is still an int, not a float
> >>> [(type(x)==int and [float(x)] or [x])[0] for x in l]
>['foo', 0.0]
> >>> # ok, that's better

And a nice subtle catch.

Alan G.

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to