An: python-list@python.org
Betreff: calling a class instance of function
>
> class pid:
> "pid"
> def add(original_pid,toadd):
> "add pid"
> original_pid.append(toadd)
> return original_pid
> def
On 20 dic, 21:09, Pyenos <[EMAIL PROTECTED]> wrote:
> class pid:
> "pid"
> def add(original_pid,toadd):
> "add pid"
> original_pid.append(toadd)
> return original_pid
For a method, you have to include an *explicit* first parameter
(usually called "self") that refers
On Wed, December 20, 2006 22:09, Pyenos wrote:
> class pid:
> "pid"
> def add(original_pid,toadd):
[...]
> def remove(something_to_remove_from,what):
[...]
> def modify(source,element,changewiththis):
[...]
> why do i get an error?
Did you copy'n'pasted the code here or typed it d
Brett Hoerner wrote:
> 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.
Sorry, never mind this bit, I misread the line. But you do probably
want to change the class test into a function test.
Bret
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
class pid:
"pid"
def add(original_pid,toadd):
"add pid"
original_pid.append(toadd)
return original_pid
def remove(something_to_remove_from,what):
"remove pid"
something_to_remove_from.remove(what)
return something_to_remove_from
def m