another easy (im sure) newbie question

Shaun Hogan shogan at iel.ie
Wed Mar 1 09:07:42 EST 2000


ok i started learning python a week ago.
ive followed Guido's tutorial and another one, i have a good grasp of everthing up to Classes, now the example in the tutorial 9.3.2:

                        class MyClass:
                                 "A simple example class"
                                 i = 12345
                                 def f(x):
                                     return 'hello world'
is where i am at.
the tutorial says "MyClass.i and MyClass.f are valid attribute references, returning an integer and a function object,"
MyClass.i returns "12345" fine...but MyClass.f gives me "<unbound method MyClass.f>"
how do i get it to return "hello world" or whatever its supposed to do?

also what does the error message "TypeError: unbound method must be called with class instance 1st argument" mean???

simple answers im sure, but its got me stuck.
any help would be great 
thanks
Shaun

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20000301/bc8bd203/attachment.html>


More information about the Python-list mailing list