[Python-Dev] Let's get rid of unbound methods (original) (raw)

Glyph Lefkowitz glyph at divmod.com
Wed Jan 5 16:37:16 CET 2005


On Tue, 2005-01-04 at 22:12 -0500, Bob Ippolito wrote:

If you have a class hierarchy where this is a problem, it's probably pretty fragile to begin with, and you should think about making it simpler.

I agree with James's rant almost entirely, but I like super() anyway. I think it is an indication not of a new weakness of super(), but of a long-standing weakness of init.

One approach I have taken in order to avoid copiously over-documenting every super() using class is to decouple different phases of initialization by making init as simple as possible (setting a few attributes, resisting the temptation to calculate things), and then providing class methods like '.fromString' or '.forUnserialize' that create instances that have been completely constructed for a particular purpose. That way the signatures are much more likely to line up across inheritance hierarchies. Perhaps this should be a suggested "best practice" when using super() as well?



More information about the Python-Dev mailing list