Bidirectional communication through pipes: read/write popen()
Fredrik Lundh
fredrik at pythonware.com
Sun Oct 17 08:33:12 EDT 1999
Oleg Broytmann <phd at sun.med.ru> wrote:
> On 17 Oct 1999, Hrvoje Niksic wrote:
> > def rwpopen(input, command, args=[]):
> ^^^^^^^
> There was well-know problem with passing mutable object as a default.
> Not sure if it was fixed in recent versions of Python...
well, that's only a problem if you modify the object
inside the function...
(and no, it hasn't been fixed. I doubt it can be
fixed without breaking stuff).
...
but to make the code a bit more flexible, I'd change
the execvp call to:
os.execvp(command, (command,) + tuple(args))
or, if you prefer:
os.execvp(command, [command] + list(args))
(this allows the caller to use *any* kind of sequence,
not just a list).
</F>
<!-- coming monday:
http://www.pythonware.com/people/fredrik/librarybook.htm
(the eff-bot guide to) the standard python library. -->
More information about the Python-list
mailing list