A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2001-August/017227.html below:

copy, len and the like as 'object' methods?

[Python-Dev] Re: copy, len and the like as 'object' methods? [Python-Dev] Re: copy, len and the like as 'object' methods?Moore, Paul Paul.Moore@atosorigin.com
Thu, 23 Aug 2001 10:12:45 +0100
> I can appreciate that your tastes are different from
> mine...in fact I said something similar to David when he
> first suggested it to me but on reflection it seemed such
> a subtle thing when compared against the weirdness of the
> definition of len:
>
>    def len(obj):
>        return obj.__length__()
>
> It does a little bit more but not much!

A strange thought, but with the advent of type/class unification and the
'object' base class, is it possible to inject new methods into the 'object'
type at runtime, allowing:

    def len(self):
        return self.__length__()
    object.len = len

This would seem quite slick (or is that "sick" :-), but it makes the
language seem more mutable than might be healthy... (Or is 'object' not this
mutable...? Must try 2.2a2 and see...)

Paul.



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4