Hi,
Methods i.e functions bound to a class instance (or object) the self argument
in their definition:
[code]
class pid:
def add(self, toadd):
pass #or some sensible code
[/code]
If you want to define a method without that implicit self argument you'll have
to make this method a st
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