Re: Adding code and methods to a class dynamically

2005-07-29 Thread Peter Hansen
Sarir Khamsi wrote: > Peter Hansen <[EMAIL PROTECTED]> 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

Re: Adding code and methods to a class dynamically

2005-07-29 Thread Sarir Khamsi
Peter Hansen <[EMAIL PROTECTED]> 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

Re: Adding code and methods to a class dynamically

2005-07-28 Thread Peter Hansen
Sarir Khamsi wrote: > 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. I'm not sure what "completion" means in this case, and I'm not aware of any "command-line comp

Re: Adding code and methods to a class dynamically

2005-07-28 Thread Sarir Khamsi
Peter Hansen <[EMAIL PROTECTED]> 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_'

Re: Adding code and methods to a class dynamically

2005-07-28 Thread Peter Hansen
Sarir Khamsi wrote: > I have a class (Command) that derives from cmd.Cmd and I want to add > methods to it dynamically. I've added a do_alias() method and it would > be nice if I could turn an alias command into a real method of Command > (that way the user could get help and name completion). The

Adding code and methods to a class dynamically

2005-07-28 Thread Sarir Khamsi
I have a class (Command) that derives from cmd.Cmd and I want to add methods to it dynamically. I've added a do_alias() method and it would be nice if I could turn an alias command into a real method of Command (that way the user could get help and name completion). The code would be generated dyna