global name not defined :$
fredrik at pythonware.com
Mon Jun 20 15:09:52 CEST 2005
"Anna M." <anna-s at internet.is> wrote:
> I am trying to write a red-black tree implementation in python. I am very
> new to python and appologize if my question is terribly stubid. But I ran
> into some trouble. I have a class and in it there are functions but when I
> try to run the code I have I just get an error on one of the functions
> "global name 'balancedFourNode' is not defined" Now of course I realize
> that I am doing something wrong when defining the function but I just can't
> seem to find it.
> Any insight would be greatly appreciated.
classes have methods, not functions.
if "x" is an instance of a class and "method" is a method defined by that
class, you should use "x.method()" to call the method.
if you're trying to call the method from another method in the same class,
if you type "method" or "method(x)", Python won't know where to look.
More information about the Python-list