On Mon, Mar 30, 2009 at 05:00:42PM +0200, Iwan Vosloo wrote:
> (Pdb) value.__class__
> <class 'decimal.Decimal'>
> 
> And yet:
> (Pdb) value.__class__ is Decimal
> False
> 
> Seems like the imported Decimal and the Decimal of which value is an
> instance are not the same thing.
> 
> Specifically, the imported Decimal seems to the the "right" one, since:
> (Pdb) Decimal is getattr(sys.modules['decimal'],'Decimal')
> True
> 
> Where does the Decimal class come from, of which value is an instance?

   Pretty normal situations that manipulate with sys.path. One can easily
imports a module two times:

>>> import sys, os, decimal
>>> decimal.__file__
'/usr/lib/python2.5/decimal.pyc'
>>> os.chdir('/usr/lib/python2.5')
>>> sys.path.insert(0, '.')
>>> del sys.modules['decimal']
>>> import decimal as decimal2
>>> decimal2.__file__
'./decimal.pyc'
>>> decimal.Decimal is decimal2.Decimal
False

Oleg.
-- 
     Oleg Broytmann            http://phd.pp.ru/            p...@phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.

------------------------------------------------------------------------------
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to