[Tutor] (no subject)

alan.gauld@bt.com alan.gauld@bt.com
Wed, 6 Mar 2002 17:14:43 -0000


> (e.g. len(a)) and other functions I have to type the variable then a
> period then the function (e.g. a.strip()).  

This is a mess at the moment because Python is kind of 
transitioning from a mixture of object oriented and procedural 
code to pure objects ala Ruby.

len(a) is the old style procedural model and a.len() is the 
more modern OO style. Most folks seem to find the original 
style easier to learn but the OO style makes for greater 
consistency and once mastered often allows more compact code
- but thats for another day...

> Sorry for this stupid beginner question, but I'm trying to 
> figure out a rhyme and reason for when to do which.

Unfortunately there's currently no consistency. In fact 
some have two valid ways like the string methods(strip, 
split etc) which are duplicated as functions in the 
string module...

Eventually everything will have methods I suspect and then
Python will look a lot more like Ruby.

Alan G.