> class MyClass: > "A simple example class" > i = 12345 > def f(self): > return 'hello world'
Nothing wrong with this. > From here I run: > x = MyClass Here's your problem - x is a class, *not* an instance of a class (i.e. an object). Methods operate on objects, not classes. Try x = MyClass() instead to get an instance of the class. > xf = x.f > while True: > print xf() Why not try something simpler - it doesn't look like you really know what you are doing here. The while True is going to print your "hello world" until the end of time, and there is no value in assigning the function to a variable at this stage - its adding complexity which you don't seem to need at the moment... Try: x = MyClass() x.f() -- http://mail.python.org/mailman/listinfo/python-list