>     x = MyClass
>     xf = x.f
>     while True:
>        print xf()

Python has some VERY nasty gotchas concerning parenthesis (or lack
there of).

In the first line here, you assign x = MyClass. That means x becomes an
alias for the class MyClass..... not an object like you intended. Look
back at the tutorial. You simply left of the parenthesis.

Another time this may cause you headaches is with functions:

#!/usr/bin/python
def fun():
    print "Hello world!"

if __name__ == "__main__":
    fun

Run this script, and you will get no output at all. Forgetting the ()
on the end of "fun" on the last line makes the difference between
executing the function and returning a reference to it.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to