Having problem with subclass

Bruce Pearson brucep at wn.com.au
Thu Sep 30 22:09:14 EDT 2010


  Try:
import A
class Bclass(A.Aclass)
...rest of code


On 1/10/2010 9:54 AM, 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? Thanks.




More information about the Python-list mailing list