Matt McClure
Matt McClure

Reputation: 16347

Why does `ipython foo.py bar.py` only print `foo.py`'s output?

The IPython 0.13.1 documentation says:

$ ipython -h
...
Usage

    ipython [subcommand] [options] [files]

    If invoked with no options, it executes all the files listed in sequence
    and exits, use -i to enter interactive mode after running the files.
...

I have two files foo.py and bar.py.

foo.py:

print "Hi, I'm foo."

bar.py:

print "Hi, I'm bar."

I expect the following to print both files output, in the corresponding order. Instead I only get the output from the first file given on the command line.

$ ipython foo.py bar.py
Hi, I'm foo.

$ ipython bar.py foo.py
Hi, I'm bar.

Is that an implementation bug, a documentation bug, or user misunderstanding? If the latter, what should I do instead?

Upvotes: 3

Views: 85

Answers (1)

minrk
minrk

Reputation: 38598

This is a documentation failure, fixed by this Pull Request. The command

$> ipython [-i] script.py script2.py ...

behaves exactly the same as the command

$> python [-i] script.py script2.py ...

In that, script.py is run, with sys.argv of ['script.py', 'script2.py', '...'], and if -i is specified, it drops into an interactive session after running the script.

Upvotes: 2

Related Questions