Improved super/autosuper

Delaney, Timothy C (Timothy) tdelaney at
Tue Jul 6 00:20:18 CEST 2004

Delaney, Timothy C (Timothy) wrote:

[snip new super/autosuper]

Well, overnight (in the shower actually - you know how it goes) I came
up with some more ideas.

1. Why the hell am I using a metaclass?

Answer: because the original example did.

I can make it a lot more versatile by simply making autosuper a base
class. The only reason it needed to be a base class originally was that
it was manipulating private attributes.

2. Make `super` a property that returns a callable object.

If the object returned is called, it simply calls the base class method.
Any other operation (e.g. attribute access) are done on the base object.

3. Sometimes you want AttributeErrors from missing base class
attributes/methods, sometimes you don't.

Perhaps have an attribute on the object for setting whether these
exceptions should be raised or not. Or perhaps have an attribute that
returns another callable object that raises.

What should be the default - raising or not raising? Which is the most
common operation. Conversely, which is the more likely source of errors
(raising when you don't want it, not raising when you do)?

Tim Delaney

More information about the Python-list mailing list