[IPython-dev] Opening files via ipython cmdline args?

Hans Meine hans_meine at gmx.net
Fri Feb 1 11:50:40 EST 2008


Hi!

I have defined a multitude of ipython profiles for various purposes, e.g. one 
that loads fig.py module for DOM-like processing of XFig files (*).  Then, 
the first command I usually issue is 

  # ipython -p figpy

  In [1]: f = fig.File("contraction.fig")

  In [2]: _

I have defined "figpy" as a shell alias for "ipython -p figpy", but it would 
be even cooler if I could write

  # figpy contraction.fig

and be greeted with an IPython env with "f" being already setup.

AFAICS, direct loading of files from the commandline could be useful for many 
other cases, too (e.g. pytables, image analysis, ...).  Is this possible 
today?

I know I can access sys.argv from ipy_profile_....py, but how can I tell 
ipython to ignore the filename afterwards?  See the attached try of removing 
the entry from sys.argv, but ipython seems to have copied the args 
beforehand:

  # ipython -p figpy contraction.fig
  ------------------------------------------------------------
     File "contraction.fig", line 9
       1200 2
            ^
  SyntaxError: invalid syntax

  WARNING: Failure executing file: <contraction.fig>

  In [1]:

Ciao, /  /
     /--/
    /  / ANS

* http://kogs-www.informatik.uni-hamburg.de/~meine/software/figpy/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ipy_profile_figpy.py
Type: application/x-python
Size: 233 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20080201/7d0a5112/attachment.bin>


More information about the IPython-dev mailing list