A Python 3000 Question

Bjoern Schliessmann usenet-mail-0306.20.chr0n0ss at spamgourmet.com
Mon Oct 29 23:08:14 CET 2007


brad wrote:
> One of the criticisms of Python compared to other OO languages is
> that it isn't OO enough or as OO as others or that it is
> inconsistent. 

If OO meant "everything must be a method" then yes, Python wasn't
OO.

> And little things such as this seem to support those 
> arguments. Not that it matters really... just seems that classes
> with methods used in a more consistent manner would be more
> appropriate in an OO langauage. Is there a reason that len cannot
> be a method?

Is there any particular reason why it should be a method?

> a_string.lower() makes sense, as does a_string.split(),
> a_string.strip()... why not a_string.len()?

Just a fuzzy comment: lower, split and strip work specifically for
strings and/or sequence types, and return a modified copy of them
(or modify them directly, as with other methods like sorted or
shuffle). len, OTOH, works for much more objects and returns some
kind of norm that makes objects comparable and whose type is the
same for all objects. 

To make a long story short: Most methods do specific things with
objects; but len is a common function to get a simple property of
an object.

Regards,


Björn

-- 
BOFH excuse #164:

root rot




More information about the Python-list mailing list