Re: [Tutor] Methods and classes

2006-09-14 Thread Alan Gauld
"Kent Johnson" <[EMAIL PROTECTED]> wrote > You have to distinguish between a method (a function that is part of > a > class definition) and a standalone function (not part of any class). > Python allows both. Standalone functions don't have a 'self' > parameter; > class methods always do (you can

Re: [Tutor] Methods and classes

2006-09-13 Thread Luke Paireepinart
[snip some] >> So just make sure I always declare self for methods (functions in >> classes)? Is this unique to python? or do some other languages already >> include self, and just hide it from the programmer? >> > > All the OO languages I know have a similar concept. Python is more > explic

Re: [Tutor] Methods and classes

2006-09-13 Thread Kent Johnson
Chris Hengge wrote: > On Wed, 2006-09-13 at 18:26 -0400, Kent Johnson wrote: >> You have to distinguish between a method (a function that is part of a >> class definition) and a standalone function (not part of any class). >> Python allows both. Standalone functions don't have a 'self' parameter

Re: [Tutor] Methods and classes

2006-09-13 Thread Chris Hengge
On Wed, 2006-09-13 at 18:26 -0400, Kent Johnson wrote: > Chris Hengge wrote: > > The deitel book has a note on page 229: > > Failure to specify an object reference (usually called self) as the > > first parameter in a method definition causes fatal logic errors when > > the method is invoked at

Re: [Tutor] Methods and classes

2006-09-13 Thread Kent Johnson
Chris Hengge wrote: > The deitel book has a note on page 229: > Failure to specify an object reference (usually called self) as the > first parameter in a method definition causes fatal logic errors when > the method is invoked at runt-ime. > > Now I've got methods all over the place among s

Re: [Tutor] Methods and classes

2006-09-13 Thread John Fouhy
On 14/09/06, Chris Hengge <[EMAIL PROTECTED]> wrote: > The deitel book has a note on page 229: >Failure to specify an object reference (usually called self) as the > first parameter in a method definition causes fatal logic errors when > the method is invoked at runt-ime. > > Now I've got m

Re: [Tutor] Methods and classes

2006-09-13 Thread Chris Hengge
OK, now that you asked for an example of a class using 'self', I can't find it..so either the thing I was reading was wrong... or I dreamed it up.. or it was something specific that I was looking at that decided I wasn't interested in and now I don't remember. As for a quick example of the method

Re: [Tutor] Methods and classes

2006-09-13 Thread John Fouhy
On 14/09/06, Chris Hengge <[EMAIL PROTECTED]> wrote: > Can anyone explain what I've been reading? I'm trying to understand why > many documents show: >def myMethod(vars): > or >class myClass(var): > and others show: >def myMetheod(self, vars) > or >class myClass(self

[Tutor] Methods and classes

2006-09-13 Thread Chris Hengge
Can anyone explain what I've been reading? I'm trying to understand why many documents show: def myMethod(vars): or class myClass(var): and others show: def myMetheod(self, vars) or class myClass(self, vars) Either way seems to work fine, so I'm not sure what it ha