newbie class question
Roland Mas
mas at echo.fr
Sun Aug 13 16:57:55 EDT 2000
Ron Johnson, Jr. (2000-08-13 15:44:48 -0500) :
> What am I doing wrong when trying tp access the method f() ?
>
> >>> class MyClass:
> ... i = 12345
> ... def f(x):
> ... return 'hello world'
>
> >>> x = MyClass
Here. x is assigned your class, and not an instance of it.
> >>> print x.i
> 12345
> >>> print x.f(1)
And here, too. x.f() is what it should read.
> Traceback (innermost last):
> File "<stdin>", line 1, in ?
> TypeError: unbound method must be called with class instance 1st
> argument
> >>> print x.f(self)
> Traceback (innermost last):
> File "<stdin>", line 1, in ?
> NameError:
> self
Roland.
--
Roland Mas
Bonjour, je suis un virus de signature. Propagez-moi dans la vôtre !
More information about the Python-list
mailing list