[Python-ideas] class-only methods without using metaclasses

Greg Ewing greg.ewing at canterbury.ac.nz
Fri Mar 8 00:02:11 CET 2013


Nick Coghlan wrote:
> It's too much additional complexity to resolve a largely theoretical
> problem.

In Python 2 you could get class-only methods like this:

    class Foo(object):

       class __metaclass__(type):

          def classmeth(cls):
             ...

I'm mildly disappointed that this can't be done any more
in Python 3. Sometimes you need genuine metaclass methods,
e.g. __xxx__ methods for a class rather than an instance.

-- 
Greg



More information about the Python-ideas mailing list