Musings about Python syntax

Fredrik Lundh fredrik at pythonware.com
Wed Oct 20 02:19:59 EDT 1999


William Tanksley <wtanksle at hawking.armored.net> wrote:
> Someone else poionted out that member functions versus unqualified
> function calls are not a valid way to distinguish OO from non-OO.  This is
> true in general, but Python is a little different -- your judgement, as
> tainted as it is by OO-propaganda, happens to be correct in this one case.

can you elaborate?

after all, the built-in len function looks something
like this:

    def len(obj):
        if hasinterface(obj, as_sequence):
            return obj.sequence_length()
        if hasinterface(obj, as_mapping):
            return obj.mapping_length()
        raise TypeError, "len() of unsized object"

which, for my non-purist eyes, surely looks as if
Python treats "obj" as an arbitrary object.

</F>

<!-- (the eff-bot guide to) the standard python library:
http://www.pythonware.com/people/fredrik/librarybook.htm
-->





More information about the Python-list mailing list