[Tutor] methods versus functions (using lists as an example)
maxnoel_fr at yahoo.fr
Tue Oct 19 17:05:19 CEST 2004
On Oct 19, 2004, at 15:29, Hans Fangohr wrote:
> Dear all,
> I was looking at what you can do with lists in Python. There are
> basically two sets of commands: (i) methods doing something with a
> list (such as sort(), reverse(), count(), ...) and (ii) functions that
> take a list as an argument (such as sum(), max(), min()).
> I would expect that there is a rationale behind this choice -- would
> anyone know what this is or where I can find more information?
> Many thanks,
It's a matter of legacy. IIRC, Python was not, in its original design,
fully object-oriented. Which is why some functions haven't been
implemented as base class methods yet.
This makes Python slightly less elegant than Ruby, but it's quite easy
to get the hang of. Hopefully this problem will be corrected in
subsequent versions of the language?
maxnoel_fr at yahoo dot fr -- ICQ #85274019
"Look at you hacker... A pathetic creature of meat and bone, panting
and sweating as you run through my corridors... How can you challenge a
perfect, immortal machine?"
More information about the Tutor