Newbie question: how to join a list of elements of user-defined types?

Alex Martelli aleax at aleax.it
Thu May 2 15:37:36 EDT 2002


Kragen Sitaker wrote:
        ...
> Apparently; class members and methods are a brand new addition in
> Python 2.2.  I think they are a major design error; they add no power
> but significant complexity to the language, and they are clumsy to
> use and bug-prone.

"class members" (attributes of a class object) are definitely no "brand
new addition" -- they've been around forever (most often, any method
you call on an instance is an attribute of its class object or one of the
latter's bases).  class methods, as well as static methods, are indeed
new, and I won't argue for them (I'm still waiting for the Smalltalkers
who clamored so hard for them to explain to me what makes them so
much better than ordinary factory functions -- I haven't understood
yet, despite a couple of attempts).

The complexity that staticmethod adds to the language is no more 
than would be added by defining its 2.1 equivalent, of course:

class staticmethod:
    def __init__(self, callable): self.__call__=callable

So, the complexity can't really be much (about on a par with the rather
modest usefulness).  I suspect that's not one of the issues you're
addressing, but it's hard to say given that "class members" mystery.


Alex




More information about the Python-list mailing list