On Fri, Nov 30, 2012 at 1:59 AM, lars van gemerden <l...@rational-it.com> wrote:
> Basically if i import a class as:
>
>     from mod1.mod2 import A
>
> or:
>
>     from mod0.mod1.mod2 import A
>
> which both result in importing the same class, a call to isinstance(inst, A) 
> in another module can have a different output.

What you may be seeing there is that you've imported the module twice.
There are two entirely separate module objects, taken from the same
file. Something instantiated from one class isn't an instance of the
other class even if they're indistinguishable classes; a little
monkeypatching might show you what's going on (fiddle with one class,
check the other, fiddle hasn't happened).

As a general rule, importing a module in different ways is considered
dangerous. Be consistent, and then this sort of oddity won't occur -
and you also won't have other oddities, eg with other global state.

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to