Wow -- thanks, guys. And who said Python only gives you one way to do
things. :-)  Metaclasses, globals(), and __subclasses__. Thank Duncan
for the __subclassess__ tip -- I didn't know about that.

I'd totally overlooked globals(). It's exactly what I was looking for
-- thanks, Peter. And I like your is_true_subclass() helper function
too.

I must say, I found it a bit weird that the first argument to
issubclass() *has* to be a class. I would have thought issubclass(42,
MyClass) would simply return False, because 42 is definitely not a
subclass of MyClass. But I guess "explicit is better than implicit",
and being implicit here might mask bugs.

globals() feels like the "right" way to do what I want -- fairly
simple and direct. Metaclasses are cool, but probably a touch too
complicated for this. And __subclassess__ seems a bit undocumented and
perhaps implementation-defined.

Cheers,
Ben.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to