[Tutor] object orientation
Andreas Kostyrka
andreas at kostyrka.org
Mon Nov 15 10:39:04 CET 2004
On Sun, Nov 14, 2004 at 09:40:03PM -0800, Christian Meesters wrote:
> Hi
>
> These days I was reading a discussion between "Ruby-people" and
> "Python-people" (us) on pros and cons of each language. Such
> discussions aren't very meaningful, of course, but sometimes
> interesting. One of the arguments was about the realization of the
> OO-approach in the languages. And this leads me to my question: Though
> I like the Python syntax and actually prefer it above Ruby's, I wanted
> to know why we write len(x) instead of x.len() (x being a string for
> instance). Does anybody know an essay / link about why this approach
> was chosen? It makes sense within Python, of course, but for now I'm
> merely interested in the history. My own screenings of the web didn't
> bring up anything useful about this topic.
Basically historical, but if you prefer the object oriented approach:
>>> [].__len__()
0
>>> "ABC".__len__()
3
>>> (1,2,3).__len__()
3
Andreas
More information about the Tutor
mailing list