Chapter 9 Tutorial for Classes Not Working
- From: Tom Grove <thomas.grove@xxxxxxxxxx>
- Date: Fri, 30 Jun 2006 10:27:32 -0400
Here is my version:
Python 2.4.3 (#2, May 9 2006, 21:56:54)
[GCC 3.4.4 [FreeBSD] 20050518] on freebsd6
I am trying the classes example from the tutorial because some other class related stuff I am doing is not working either.
Straight from Chapter 9:
class MyClass:
"A simple example class"
i = 12345
def f(self):
return 'hello world'
From here I run:
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!
-Tom
.
- Follow-Ups:
- Re: Chapter 9 Tutorial for Classes Not Working
- From: tac-tics
- Re: Chapter 9 Tutorial for Classes Not Working
- From: Ant
- Re: Chapter 9 Tutorial for Classes Not Working
- From: Damjan
- Re: Chapter 9 Tutorial for Classes Not Working
- Prev by Date: Re: string replace
- Next by Date: Re: string replace
- Previous by thread: print shell output in a file
- Next by thread: Re: Chapter 9 Tutorial for Classes Not Working
- Index(es):
Relevant Pages
|