[IPython-user] Specifying argv as a list
asheesh at asheesh.org
Wed Jun 21 16:21:22 CDT 2006
One problem with the shell is the difficulty of expressing the argv, which
is truly a list, in space-delimited form. The space-delimted arguments
becomes a problem when you accept variables from others, for example;
shell metacharacters have to be escaped, and this is often a troublesome
problem. It also goes against the "Explicit is better than implicit"
guideline of Python.
Is there a way for me to type out arguments to regular UNIX programs as a
list rather than an implicit list separated by " "?
The best user interface I can imagine to this is that when you type "!ls"
and press space, the input transforms before your eyes to:
! ["ls", "
I might then press the hyphen key, the 'l' key, and then enter, and the
command-line would autocomplete that to:
! ["ls", "-l"])
and then show me the output.
A basic version would simply allow me to manually type:
and show me the result as I'd expect.
I like showing argv to the user as a list because that's precisely what it
is. This also allows more natural variable insertion and Python
integration. For example:
! ['rm', RMARG, '''Some "loser"'s file''']
Depart not from the path which fate has assigned you.
More information about the IPython-user