Todd Matsumoto wrote:
Hi,

Thanks for all the comments so far.

DaveA, I'm receiving the value via pyODBC, after running a query on a database. 
The test is to first make sure the value is a Decimal (pyODBC returns a Decimal 
object if what is coming from the database is a decimal type). So if I don't 
have a value that is a Decimal object something is wrong.

Cheers,

T
-------- Original-Nachricht --------
Datum: Tue, 14 Jul 2009 22:36:14 -0400
Von: Dave Angel <da...@ieee.org>
An: CC: Todd Matsumoto <tmatsum...@gmx.net>, tutor@python.org
Betreff: Re: Re: [Tutor] unittests, testing a type

On Tue, Jul 14, 2009 at 9:59 AM, Todd Matsumoto<tmatsum...@gmx.net> wrote:
The reason why is I'm receiving the Decimal value from another program,
if I already know that the value will be a Decimal why test it?
How are you receiving it? File, pickle, pipe, socket, exit() return value? When I first read your question, I assumed you meant "from another module." But if it's another process, then you'd better tell us how you're actually getting the value. Maybe it's a Decimal because you just got done converting it to one.

DaveA

If the value is being passed back from another module, and you therefore
want to do an exact test on the type, just do
   if  type(a) == decimal.Decimal:

On the other hand, if you just want to know if it's a particular type,
or some subclass of that type, use  isinstance();.

DaveA



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

Reply via email to