On Sep 29, 12:08 am, Terry Reedy <[EMAIL PROTECTED]> wrote:

> George Sakkis wrote:
> > On Sep 28, 2:29 pm, process <[EMAIL PROTECTED]> wrote:
>
> >> I have heard some criticism about Python, that it is not fully object-
> >> oriented.
>
> > That's not a bug, it's a feature ;-)
>
> >> Why isn't len implemented as a str.len and list.len method instead of
> >> a len(list) function?
>
> > As Terry Reedy wrote, partly history and partly practicality. There's
> > no philosophical reason why we write "len(x)" (generic builtin),
> > "x.append(1)" (method) or "del x[i]" (statement). The latter in
> > particular is IMHO a design wart; there's no reason for not writing it
> > as "x.delete(i)".
>
> As a general rule and matter of practice, methods that apply to all or
> most classes (or all number classes) have built-in functions that call
> the corresponding special method (or C-level slot).

It would be easier to justify this rule if it was more clear-cut, and
specifically if it was applied only to methods that are available to
*all* classes (such as type() and getattr()) rather than the ill-
defined "most classes".

George
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to