[IPython-user] Notes on using ipython as a system shell ('pysh')

Prabhu Ramachandran prabhu_r at hathway.com
Tue Apr 13 03:48:57 CDT 2004

>>>>> "FP" == Fernando Perez <Fernando.Perez at colorado.edu> writes:

    FP> 4.  It should also be possible to expand python
    FP>     variables/commands in the
    FP> middle of system commands.  I thihk this will make it
    FP> necessary to use $var for name expansions:

    >>> var='hello' # var is a Python variable print var
    FP> hello # This is the result of a Python print command
    >>> echo $var
    FP> hello # This calls the echo command, expanding 'var'.

Everything else sounds nice.  I am not comfortable with '$var'.  What
I would really like to see is that variables are just like any other
Python variable.  Its just that shell commands are part of the
vocabulary.  Or is that hard to implement?  For example:

 >> var = 'hello'
 >> echo var + ' world!'
 hello world!

The only trouble is that there are shell commands that mirror Python
keywords.  import is one such example.  import is part of ImageMagick.
Anyway, you do address this later.

Also can pipes be handled?

 >> ps uax | grep ipython | sort > /tmp/ps

    FP> It should be possible to write code like:

    >>> for ext in ['.jpg','.gif']:
    FP> ..  ls file$ext

How about:
 >> for ext in [...]:
 ..  ls file + ext

Its illegal syntax but its the shell and there are no funny $'s to
worry about.  The trouble with the $ is that it tends to make things a
little confusing.  Without the $, everything is just pure Python with
shell commands thrown in.


    FP> - it's ok for shell builtins (in this case this includes the
    FP>   python language)
    FP> to override system commands on the path.  See tcsh's 'time' vs
    FP> '/usr/bin/time'.  This settles the 'print' issue and related.
    FP> - pysh should take
    FP> foo args
    FP> as a command if (foo args is NOT valid python) and (foo is in
    FP> $PATH).
    FP> If the user types
    >>> ./foo args
    FP> it should be considered a system command always.

Or better, the good old:

 >> !foo args

since . may not contain foo.

Anyway, this sounds terrific and I look forward to it.  Considering
how horribly addicted I am to tab-completion, the only problem is that
if pysh does become a reality, many of us would be handicapped on any
other shell. ;-)


More information about the IPython-user mailing list