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 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_'

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

Re: Interpreter-like help in cmd.Cmd

2005-06-09 Thread Sarir Khamsi
Peter Hansen <[EMAIL PROTECTED]> writes: > class _Helper(object): > """Define the built-in 'help'. > This is a wrapper around pydoc.help (with a twist). > > """ > > def __repr__(self): > return "Type help() for interactive help, " \ > "or help(object) f

Interpreter-like help in cmd.Cmd

2005-06-09 Thread Sarir Khamsi
Is there a way to get help the way you get it from the Python interpreter (eg, 'help(dir)' gives help on the 'dir' command) in the module cmd.Cmd? I know how to add commands and help text to cmd.Cmd but I would also like to get the man-page-like help for classes and functions. Does anyone know how

Re: sending signals to child process

2005-04-08 Thread Sarir Khamsi
"Diez B. Roggisch" <[EMAIL PROTECTED]> writes: > Sarir Khamsi wrote: > >> I would like to start a child process (like w/ popen3(), or some such) >> and then be able to interrupt it by sending it a control-c. How do I >> do that in Python? Is there a bette

sending signals to child process

2005-04-08 Thread Sarir Khamsi
I would like to start a child process (like w/ popen3(), or some such) and then be able to interrupt it by sending it a control-c. How do I do that in Python? Is there a better way to gracefully halt a child process? Is there a more cross-platform way to start a child process (popen() is only on UN

instance vs class attributes

2005-03-29 Thread Sarir Khamsi
I come from a C++ background and am learning some of the details of Python's OO capability and now have some questions. Given: #!/bin/env python class A(object): _x = 10 def __init__(self): self.x = 20 def square(self): return self.x * self.x print 'A.x = %d' % A._x a = A() print 'a.x =