self argument
Jason Stokes
jstok at bluedog.apana.org.au
Sat Feb 26 13:17:10 EST 2000
More information about the Python-list mailing list
Sat Feb 26 13:17:10 EST 2000
- Previous message (by thread): self argument
- Next message (by thread): self argument
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
london999 at my-deja.com wrote in message <8984mm$5pi$1 at nnrp1.deja.com>... >I am very new to Python, but it appears that every function defined in a >class must have self as a first variable name. No. You're just a little confused on a couple of points. Firstly, member functions always receive the invoked upon class instance as the first argument. The convention is to call this argument "self", but there's no requirement to do so. Secondly, not all functions are members of a class. Functions that are not class members don't receive this implicit argument; this way, you can program in conventional functional or procedural style. > Even better, it would be nice (probably too late >I know), if self was defined implicitly as the "this" pointer is in C++. I'm not sure why Python's way was chosen, but you get used to it.
- Previous message (by thread): self argument
- Next message (by thread): self argument
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list