Static class methods

Alex Martelli aleaxit at yahoo.com
Tue Mar 6 03:05:23 EST 2001


"Alex Shindich" <alex at shindich.com> wrote in message
news:7SZo6.7063$qv3.3125634 at nnrp5-w.sbc.net...
> There are indeed many ways to simulate the behavior. But shouldn't such a
> strong OOP language like Python have support for static methods?

I don't think it should, not necessarily.  OOP does not have to
mean class-centered; Python does offer classes, but does not
focus on them the way some other OOP languages (such as Eiffel)
do -- rather, Python offers different kinds of objects for
different purposes.

Thus, there is no necessary reason why functions that are
not associated with a specific instance should _have_ to be
connected to a class-object rather than to a module-object
(or other kinds of objects yet -- remember that packages
as well as modules exist, for example).

I suspect that the strong desire to associate such functions
with class-objects may come from previous experience with
languages which gave one no real alternative regarding the
organizing-objects choice for subsystems, besides classes.

Personally, I don't feel any particular constraint from not
being able to assign functions as class-object attributes,
any more than I do for the similar inability regarding, say,
dictionaries, or lists, or tuples.  Sure, some more flexibility
would not be a problem (unless it imposed costs elsewhere), but
nor would it make my Python use any more 'object-oriented' --
at most, it would move some of my functions from attributes of
objects of one kind to attributes of objects of another kind.


Alex






More information about the Python-list mailing list