get a list of classes in this module
tanzer at swing.co.at
Thu Jun 13 02:21:34 EDT 2002
"Mark McEahern" <marklists at mceahern.com> wrote:
> Yeah, it's not so much that I don't trust myself--there's that. ;-) But
> it's also the simple DRY principle at work. Why should I have to list the
> classes in that factory-like dictionary when Python can do that for me?
> Thankfully, I didn't have to resort to globals()--but took advantage of
> Python 2.2's __subclasses__ (which requires subclassing the base class from
> object). That worked smoov.
I'd recommend to use a custom metaclass to put the classes in question
into the dictionary -- this way some other module can add credit card
classes and it should still work.
Christian Tanzer tanzer at swing.co.at
Glasauergasse 32 Tel: +43 1 876 62 36
A-1130 Vienna, Austria Fax: +43 1 877 66 92
More information about the Python-list