Re: Chapter 9 Tutorial for Classes Not Working
- From: Damjan <gdamjan@xxxxxxxxx>
- Date: Fri, 30 Jun 2006 17:00:32 +0200
class MyClass:
"A simple example class"
i = 12345
def f(self):
return 'hello world'
From here I run:
x = MyClass
Did you mean x = MyClass()
xf = x.f
while True:
print xf()
This gives the following error:
Traceback (most recent call last):
File "<stdin>", line 2, in ?
TypeError: unbound method f() must be called with MyClass instance as
first argument (got nothing instead)
Please help...this is killing me!
What you are really calling is MyClass.f without any arguments.
--
damjan
.
- References:
- Chapter 9 Tutorial for Classes Not Working
- From: Tom Grove
- Chapter 9 Tutorial for Classes Not Working
- Prev by Date: Re: print shell output in a file
- Next by Date: Re: Way for see if dict has a key
- Previous by thread: Chapter 9 Tutorial for Classes Not Working
- Next by thread: Re: Chapter 9 Tutorial for Classes Not Working
- Index(es):
Relevant Pages
|