[IPython-user] Inconsistency in "!!" ?
walter at livinglogic.de
Fri Jun 23 03:01:45 CDT 2006
Krishna Mohan Gundu wrote:
>>> For more info see http://projects.scipy.org/ipython/ipython/wiki/UsingIPipe
> Thanks for the link Walter. Interesting stuff in there.
>> Implementing !/!! so that they would work inside arbitrary statements
>> would be very complex, now it's just
> I have been making a note to myself as to what I felt are
> inconsistencies in regards to the shell behavior. Probably this is the
> best place to mention them.
> 1) var = !command => both outputs and assigns the result. Should there
> be output?
> 2) \tab+ $[$]var = command => syntax error.
> 3) no variable substitution in sout(command_string) and lout(command_string)
> 4) absence of sout() and lout() in 'sh' profile
> Currently it all looks complicated. I suggest the following. Instead
> of making the shell command syntax open ended (actually ending in
> '\n') we use a token to signify the start and the end of a shell
> command. I suggest ``, as it is an illegal python syntax
Actually it isn't, it's a (deprecated) way of writing repr():
In : `"foo"`
> and resembles
> shell execute syntax. Something like
> [var =] ``[keyword] command``
> keyword could be (note that quotes are required to allow
> disambiguation from a command name)
> "list" - return the output as a list splitting at \n (default)
> "string" - return the output as a string
> "result" - return the exit status of command
> Each of these commands are replaced with, say, _ip.getoutput() or
> _ip.getresult() so they can be directly invoked if desired. This can
> be done with a prefilter hook. I think this reads much cleaner. What
> do you say?
Why not use plain Python syntax?
foo = `"string" ls`
isn't that much shorter than
foo = ipstring("ls")
Of course `ls` (without keyword) is hard to beat, but typing ` on a
german keyboard is cumbersome.
2/3rds of what you want is rather simple (albeit a bit longer) with ipipe:
In : foo = list(ix("ls"))
In : "\n".join(ix("ls"))
Would it make sense to add shortcuts for that?
More information about the IPython-user