calling a class instance of function

Brett Hoerner bretthoerner at gmail.com
Wed Dec 20 19:20:07 EST 2006


Pyenos wrote:
> class test(pid):
>     pid.original=[1,2,3]
>     pid.toadd=4
>     pid.add(pid.original,pid.toadd) # error here says that
>                                     # it expects pid instance as first arg
>                                     # not a list that it got.
>
> why do i get an error?

'test' is a class here, and the pid you tried to pass it is actually
the class it is inheriting from.  I think you wanted to do:

def test(pid):
    ...

Also, in order to call a function without arguments you still need to
use (), so you probably wanted to use pid.original() in your pid.add
call.

Brett Hoerner




More information about the Python-list mailing list