Re: Adding code and methods to a class dynamically
- From: Sarir Khamsi <sarir.khamsi@xxxxxxxxxxxx>
- Date: Thu, 28 Jul 2005 16:07:23 -0700
Peter Hansen <peter@xxxxxxxxxxx> writes:
> If it's truly just an alias you want, then something like this should
> work better. Replace everything in the if mo: section with this:
>
> if mo:
> newName = mo.group(1)
> existingName = mo.group(2)
> existingMethod = getattr(self, 'do_' + existingName)
> setattr(self, 'do_' + newName, existingMethod)
Thanks, this is amazingly more simple than what I had. This works
fine but I'm looking at the code for cmd and don't really see how you
get completion to work on the new alias.
Also, I would like the alias to have arguments:
alias newName existingName arg1 arg2 ...
Currying comes to mind, but I haven't tried it yet. Thanks again for
the help.
Sarir
.
- Follow-Ups:
- Re: Adding code and methods to a class dynamically
- From: Peter Hansen
- Re: Adding code and methods to a class dynamically
- References:
- Adding code and methods to a class dynamically
- From: Sarir Khamsi
- Re: Adding code and methods to a class dynamically
- From: Peter Hansen
- Adding code and methods to a class dynamically
- Prev by Date: Re: c/c++ extensions and help()
- Next by Date: Re: Ten Essential Development Practices
- Previous by thread: Re: Adding code and methods to a class dynamically
- Next by thread: Re: Adding code and methods to a class dynamically
- Index(es):
Relevant Pages
|