DRY and class variables
egbert
egbertum at xs4all.nl
Thu Sep 8 16:53:35 EDT 2011
On Thu, Sep 08, 2011 at 12:22:33PM +0200, Thomas Jollans wrote:
> You should be able to do this with a metaclass (almost certainly
> overkill), or with a class decorator (Python 2.6+):
>
> def with_metadata (cls):
> cls.m = Metadata (cls.__name__)
> cls.m.do_something ()
> return cls
>
> @with_metadata
> class TableOne:
> # foo
> pass
Overnight I have become a decorator fan.
I can postpone the study of metaclasses.
Thanks.
e
--
Egbert Bouwman - Keizersgracht 197 II - 1016 DS Amsterdam - 020 6257991
========================================================================
More information about the Python-list
mailing list