alias method definitions / syntactic sugar suggestion
tleeuwenburg at gmail.com
Fri Mar 6 05:45:31 CET 2009
On Fri, Mar 6, 2009 at 3:39 PM, Chris Rebert <clp2 at rebertia.com> wrote:
> On Thu, Mar 5, 2009 at 6:17 PM, Tennessee Leeuwenburg
> <tleeuwenburg at gmail.com> wrote:
> > I'm not sure if this problem I face affects many other people, but I'll
> > describe it and see what kind of feedback I get.
> > I have a suggestion for a new piece of Python syntax when defining
> > I have seen the following done, and have done it myself
> > class FanstasticClass:
> > def __init__(self):
> > self.someFantasticMethod("Hello")
> > def someFantasticMethod(self, argument = True):
> > print argument
> > justAsFantastic = someFantasticMethod
> This sounds like a code smell to me. You shouldn't have 2 methods with
> different names that do the same thing, it seems like bad design IMHO.
> Also, I don't think this is done anywhere near frequently enough to
> warrant new syntax. I'm -1 on the idea personally.
Yeah, I can see that. There is one instance where I've done it personally,
and another where I've seen it done.
Where I've done it personally, it was to, shall we say, compensate for a
design feature. Where I've seen it done was (I think) for
*If* you are going to have two methods with different names that do the same
thing, they *really should* execute the same lines of code! :)
The alternative of course is:
In fact, probably I should just do that... at the time it seemed appropriate
to do the alias thing.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list