python newbie: some surprises

Bruno Desthuilliers bruno.42.desthuilliers at websiteburo.invalid
Fri May 9 04:48:38 EDT 2008


v4vijayakumar a écrit :
> When I started coding in python, these two things surprised me.
> 
> 1. my code is inconsistently indented with the combination of tabs and
> spaces. Even lines looked intended, but it is not.

Then you have a problem with your code editor - not with Python.

> 2. python requires to pass "self" to all instance methods

Nope. Python requires that function used as instance methods take the 
instance as first argument (and that functions used as classmethods take 
the class as first argument). It's the method object's duty to actually 
pass the appropriate object to the function. The rational is that it 
allows to built methods above two more generic constructs (namely: 
functions and the descriptor protocol) instead of having to special-case 
them.

> and I missed ":" often. :)

Your editor should not indent the next line then. Either you failed to 
correctly configure your editor, or it's broken.



More information about the Python-list mailing list