Re: [Tutor] validating decimal class

2008-11-06 Thread A.T.Hofkamp
John Fouhy wrote: 2008/11/6 Brian Lane <[EMAIL PROTECTED]>: 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 Tru

Re: [Tutor] validating decimal class

2008-11-05 Thread John Fouhy
2008/11/6 Brian Lane <[EMAIL PROTECTED]>: > 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 --

Re: [Tutor] validating decimal class

2008-11-05 Thread Brian Lane
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 [EMAIL PROTECTED] wrote: > hello > silly question, but i can't seem to figure it it. > > I have an object which is: > type(price) > > > but i can't figure how to validate against it. > if not isinstance(price, decimal.Decimal): >

Re: [Tutor] validating decimal class

2008-11-05 Thread Kent Johnson
On Wed, Nov 5, 2008 at 7:09 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > I have an object which is: > type(price) > > > but i can't figure how to validate against it. > if not isinstance(price, decimal.Decimal): > do something... This should work, what problem are you havi

[Tutor] validating decimal class

2008-11-05 Thread [EMAIL PROTECTED]
hello silly question, but i can't seem to figure it it. I have an object which is: >>> type(price) but i can't figure how to validate against it. >>>if not isinstance(price, decimal.Decimal): do something... how do i ensure that the object 'price' is a decimal? thanks