def index(self):

Gert Cuykens gert.cuykens at gmail.com
Thu Dec 21 18:07:45 EST 2006


On 21 Dec 2006 09:44:48 GMT, Duncan Booth <duncan.booth at invalid.invalid> wrote:
> "George Sakkis" <george.sakkis at gmail.com> wrote:
>
> @expr
> def fn(...): ...
>
> is exactly equivalent to:
>
> def fn(...): ...
> fn = (expr)(fn)
>

ok i did my homework reading about decorators
http://www.python.org/doc/2.4.4/whatsnew/node6.html

could it be the example above needs to be like

@expr
def fn(...): ...

is exactly equivalent to:

def fn(...): ...
fn = expr(fn)

> > oh and self stands more or less for private method right ?
>
> if you have to ask that question about 'self' you really do need to read
> some introductory texts on Python.
>
> Methods get passed their instance as their first parameter (usually this is
> implicit in the call, but it is always explicitly shown in the method) and
> self is simply the conventional name. Many other languages use 'this'
> instead of self and make the passing of 'this' implicit inside the method
> as well as outside. There are good reasons why it is explicit in Python,
> but just remember that the first parameter a method receives is always the
> instance and you won't go far wrong.

in all the things i every read about self i end up with blablabla
scoping blabla blabla self:: blablabla public static methods blablabla
:)

So when reading 'self' is the same as 'this' it was worth asking the
question for confusion sake :)



More information about the Python-list mailing list