Adding code and methods to a class dynamically
Peter Hansen
peter at engcorp.com
Fri Jul 29 17:10:40 EDT 2005
Sarir Khamsi wrote:
> Peter Hansen <peter at engcorp.com> writes:
>>I'm not sure what "completion" means in this case, and I'm not aware
>>of any "command-line completion" support in cmd.Cmd though it may well
>>be there, so I can't say. Certainly there is nothing in any way
>>different about the new attribute created by the alias code, as both
>>it and the original attribute are bound to exactly the same method.
>
> If you have the readline module, you get TAB command completion for
> free (a la bash, emacs, etc)...or maybe readline only gives you
> emacs-style command history editing, or both...not sure.
Cool. The answer to whether a particular approach preserves command
completion ability then, unfortunately, depends on how it's implemented.
If it's totally dynamic, then the aliases my approach created will be
supported, but if it's done at Cmd creation time, or in some other
static manner, the dynamically created aliases won't be found.
-Peter
More information about the Python-list
mailing list