[Tutor] validating decimal class

John Fouhy john at fouhy.net
Thu Nov 6 03:16:42 CET 2008


2008/11/6 Brian Lane <bcl at brianlane.com>:
> But you could also compare it to a known type:
>
> if not type(price) is type(decimal.Decimal(0)):
>  print "Not Decimal"

Easier to just compare with decimal.Decimal:

>>> import decimal
>>> d = decimal.Decimal(13)
>>> type(d) == decimal.Decimal
True

-- 
John.


More information about the Tutor mailing list