Abstract Base Class register function

Mikolai Fajer mfajer at gmail.com
Sat Sep 27 17:50:26 EDT 2008


I have been experimenting with the abc module in py3k and thought
about using the register method of an ABC as a class decorator:

<code>
import abc
class MyABC(metaclass=abc.ABCMeta):
    pass

@MyABC.register
class MySub():
    pass
</code>

This doesn't work because the register method returns None.  It would
be a fairly simple modification to have this work:

<code>
    def register(cls, subclass):
        """Register a virtual subclass of an ABC."""
        ... etc ...
        return subclass
</code>

What do people think of this behavior?

-- 

     -Mikolai Fajer-



More information about the Python-list mailing list