class of a class problem

John J. Lee jjl at pobox.com
Mon May 12 18:41:21 EDT 2003


CipoFuzo <cipofuzo at home.com> writes:

> I'm trying to define a class inside of a class
> and it doesn't work:
[...]
> Why do I get a namerror? Why is python looking for B in
> the global namespace?

 
class A:
    class B:
        pass               
    def __init__(self):
-       self.element = B()
+       self.element = self.B()

test = A()


John




More information about the Python-list mailing list