Alias for an attribute defined in a superclass

Ben Finney ben+python at
Fri Apr 1 00:14:03 CEST 2011

Howdy all,

I want to inherit from a class, and define aliases for many of its
attributes. How can I refer to “the attribute that will be available by
name ‘spam’ once this class is defined”?

    class Foo(object):
        def spam(self):

        def eggs(self):

    class Bar(Foo):
        beans = Foo.spam
        mash = Foo.eggs

Is that the right way to do it? Will that leave me open to “unbound
method” or “is not an instance of ‘Bar’” or other problems when using

 \           “If [a technology company] has confidence in their future |
  `\      ability to innovate, the importance they place on protecting |
_o__)     their past innovations really should decline.” —Gary Barnett |
Ben Finney

More information about the Python-list mailing list