From: Chris Bergstresser <chris@su...> - 2009-03-22 20:16:46
Hi all --
Is there a reason docutils.parsers.rst.Directive doesn't inherit
from object? I was trying to add a metaclass to my subclasses, but if
they're not new-style classes I can't.
Actually, is there a better way to do this? I'd like to subclass
Directive, and then have my subclasses inherit from that subclass and
share some initialization and behavior code. But Docutils passes
around classes and uses their attributes in the parser, so I never get
an opportunity to do things during initialization. I can't use class
decorators in 2.5, and I can't use metaclasses without new-style
classes. I suppose I could create my own register_directive function
and do the magic in there, but that seems a little odd.
From: Ben Finney <ben+python@be...> - 2009-03-23 00:45:55
Chris Bergstresser <chris@...> writes:
> Is there a reason docutils.parsers.rst.Directive doesn't inherit
> from object? I was trying to add a metaclass to my subclasses, but if
> they're not new-style classes I can't.
You can work around it by inheriting from ‘object’ as well as the
desired base class::
class SpankingNew(CruftyOld, object):
\ “[Freedom of speech] isn't something somebody else gives you. |
`\ That's something you give to yourself.” —_Hocus Pocus_, Kurt |
_o__) Vonnegut |
Ben Finney <ben@...>
Get latest updates about Open Source Projects, Conferences and News.