Method or function?

Cliff Crawford cjc26 at nospam.cornell.edu
Tue Oct 31 11:19:18 EST 2000


* Dale Strickland-Clark <dale at out-think.NOSPAMco.uk> menulis:
| I dare say that this has been discussed before, I just can't see it
| anywhere.  
| 
| Shouldn't these standard functions be methods of their various
| datatype classes?
| 
| [...]
| 
| Some of these are particularly odd, like those that have to be
| implemented by a special __method__, e.g. str(), repr() and len().
| 
| What's the logic behind this?

Methods which can take many different types as an argument were made
functions.  So, for example, since you can find the length of strings,
lists, and tuples, it was made a function.  Also, some of the functions
on your list, like abs, only apply to numbers; do you really want to
write (-4).abs() instead? ;)


-- 
cliff crawford  http://www.people.cornell.edu/pages/cjc26/
                But WHERE are the turtles?



More information about the Python-list mailing list