SIMPLE QUESTION

Remco Gerlich scarblac-spamtrap at pino.selwerd.nl
Tue Jul 25 07:30:24 EDT 2000


sergio wrote in comp.lang.python:
>  Hi all
>     I''ve imported a dll into a .py file, but when i try to use a
> function i get the error
> 
> Traceback (innermost last):
>   File "<interactive input>", line 0, in ?
> TypeError: unbound method must be called with class instance 1st
> argument
> 
> 
> The question is , how can i get the "class instance", or maybe i have to
> pass a string with the name of the class on the first argument.
> 
>   Thanks in advance for all your responses

You are calling a method directly on a class, instead of making an instance
of the class, and calling the method on that.

Ie,
class Example:
   def test():
      pass
	  
Now 
Example.test()
gives your error, and
e = Example()
e.test()
works.

Can't say more without more info about what you're doing.


-- 
Remco Gerlich,  scarblac at pino.selwerd.nl
  Murphy's Rules, "Atomic TNT?":
   In Aftermath (FGU), a one-ton charge of high explosive will kill
   nearly every living thing in 300 square kilometers.



More information about the Python-list mailing list