On 09/30/10 20:54, tekion wrote:
All,
I have file name A.py with a class name Aclass. I have a file name
B.py with sub class of Aclass, like
import A
class Bclass(Aclass)
...rest of code
When I test it, calling B.py, I am getting:
class Bclas(Aclass):
NameError: name 'Aclass' is not defined
When I move Bclass to A.py, it works. Is there some restriction in
python that sub classing a class has be in the same file as the class
you're are sub classing?
This is pretty straight-forward name-spacing. You can use
class Bclass(A.Aclass):
...
or
from A import Aclass
class Bclass(Aclass):
...
But in your code as it currently stands, the module "A" is the
only thing in scope, not "Aclass", so you have to either bring
Aclass into scope, or qualify it.
-tkc
--
http://mail.python.org/mailman/listinfo/python-list