I happens to have a instance where some data is in form of NaN(Not a
Number). When converted into decimal, and I have to filter those.

In many language and the latest python is a method or function in form of.
is_nan or isnan, to check it. I happen to be unlucky enough to have python
2.4 that don't have that.

Fortunately there is a way to handle this. http://en.wikipedia.org/wiki/NaN

As some might already know, Basically the idea is, for x is NaN then x == x
is false.

in python you can test it here

f = float("NaN")
if f == f:
    print "this should not print"

or in decimal module

from decimal import *
d = Decimal("NaN")
if d == d:
    print "this should not print too"

yes, it not as useful now as newer python version provide a is_nan method,
which is more intuitive.

-- 
To unsubscribe from and detail about this group 
http://portal.mosc.my/osdc-my-mailing-list-information

MOSC2011 http://fb.me/mosc2011 and http://portal.mosc.my/

Kirim email ke