[Pythonmac-SIG] Unbound method error

Peter Sommerfeld noema@csi.com
Mon, 20 Jul 1998 10:14:12 -0400 (EDT)


<fontfamily><param>Geneva</param><color><param>0000,0000,3333</param>Guido
writes in the python tutorial:


"So, if the class definition looked like this: 


<smaller>class MyClass:   

	 "A simple example class"   

	 i = 12345    

	def f(x): return 'hello world'


</smaller>then <smaller>MyClass.i</smaller> and
<smaller>MyClass.f</smaller> are valid attribute references, returning
an integer and a function object, respectively."


I understood that MyClass.f(x) is something like a static class method
in C++ because no "self" appears. So I should be able to call


MyClass.f(x)


But that doesn't work. I get "TypeError: unbound method must be called
with class instance 1st argument."


Using: Python 1.5.1, Just's IDE on Mac


What did I get wrong here ?



Thanks in advance


Peter


-- Lueneburg, Germany

</color></fontfamily>