class of a class problem

Skip Montanaro skip at pobox.com
Mon May 12 18:31:23 EDT 2003


    cipo> NameError: global name 'B' is not defined

Try:

    self.element = self.B()

or

    self.element = A.B()

instead.  You defined B inside A, so it's a class attribute of A, not a
local (or global) variable.

    cipo> Why do I get a namerror? Why is python looking for B in the global
    cipo> namespace?

It's not defined in either the local, global or builtin namespsaces.
Perhaps the message could more usefully be worded:

    NameError: name 'B' not defined in local, global or builtin namespaces

Skip





More information about the Python-list mailing list