First of all I created two files:
File which contains the base class (I called it base.py)
class A(object):
"""do something"""
def __init__(self):
print 'initializing base class'
print '__module__: ', self.__module__
print '__class__: ', self.__class__
print 'self: ', self
print
File which contains the son class (inherits from A). I called it other.py
from base import A
class A(A):
"""do the same thing as A from base"""
def __init__(self):
super(A,self).__init__()
print 'initializing son class'
print '__module__: ', self.__module__
print '__class__: ', self.__class__
print 'self: ', self
print
Notice that in the second file (other.py) the name of the class is identical to the name of its parent (A for both). For some reason the class created has priority on the namespace and overwrite the old one, which you have imported.
Now, running it:
>>> import other
>>> a = other.A()
initializing base class
__module__: other
__class__: <class 'other.A'>
self: <other.A object at 0x7f6bee790410>
initializing son class
__module__: other
__class__: <class 'other.A'>
self: <other.A object at 0x7f6bee790410>
>>> a
<other.A object at 0x7f6bee790410>
>>>
>>> dir()
['__builtins__', '__doc__', '__name__', '__package__', 'a', 'other']
>>>
Notice that your namespace just contains the module 'other', and not the base one.