Re: Pythonic way to add method alias in subclass

2007-12-15 Thread Carl Banks
On Dec 15, 8:03 am, Lee Harr <[EMAIL PROTECTED]> wrote: > I thought of several ways to add another name for > a method in a subclass ... > > #alias.py > class Foo(object): > def nod(self): > print "nodding" > > class Bar(Foo): > def __init__(self): > self.agree = self.nod >

Re: Pythonic way to add method alias in subclass

2007-12-15 Thread Bruno Desthuilliers
Lee Harr a écrit : > I thought of several ways to add another name for > a method in a subclass ... > > > #alias.py > class Foo(object): > def nod(self): > print "nodding" > > class Bar(Foo): > def __init__(self): > self.agree = self.nod Will create an instance attribute

Re: Pythonic way to add method alias in subclass

2007-12-15 Thread Steven D'Aprano
On Sat, 15 Dec 2007 13:03:33 +, Lee Harr wrote: > I thought of several ways to add another name for a method in a subclass ... > class Bar2(Foo): > agree = Foo.nod ... > I am leaning towards Bar2 since it has the least code. Sure, why not? Out of curiosity, what's wrong with just calli

Pythonic way to add method alias in subclass

2007-12-15 Thread Lee Harr
I thought of several ways to add another name for a method in a subclass ... #alias.py class Foo(object): def nod(self): print "nodding" class Bar(Foo): def __init__(self): self.agree = self.nod class Bar2(Foo): agree = Foo.nod class Bar3(Foo): def agree(self):