FAQ

Oleg Broytmann 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. -->

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 4 of 12 | next ›
Discussion Overview
grouppython-list @
categoriespython
postedOct 17, '99 at 12:47a
activeOct 27, '99 at 7:30p
posts12
users6
websitepython.org

People

Translate

site design / logo © 2021 Grokbase