Re: calling a class instance of function

2006-12-21 Thread Nils Oliver Kröger
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

Re: calling a class instance of function

2006-12-20 Thread Gabriel Genellina
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

Re: calling a class instance of function

2006-12-20 Thread Julio Biason
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

Re: calling a class instance of function

2006-12-20 Thread Brett Hoerner
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

Re: calling a class instance of function

2006-12-20 Thread Brett Hoerner
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

calling a class instance of function

2006-12-20 Thread Pyenos
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