为什么'ipython foo.py bar.py'只打印'foo.py`';谁的产量?
IPython 0.13.1文档说明:为什么'ipython foo.py bar.py'只打印'foo.py`';谁的产量?,ipython,Ipython,IPython 0.13.1文档说明: $ 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. ... 我有两个文件f
$ 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.
...
我有两个文件foo.py
和bar.py
foo.py
:
print "Hi, I'm foo."
print "Hi, I'm bar."
bar.py
:
print "Hi, I'm foo."
print "Hi, I'm bar."
我希望下面的代码能够以相应的顺序打印两个文件输出。相反,我只从命令行中给出的第一个文件中获取输出
$ ipython foo.py bar.py
Hi, I'm foo.
$ ipython bar.py foo.py
Hi, I'm bar.
这是实现错误、文档错误还是用户误解?如果是后者,我应该怎么做?这是一个文档故障,由修复。 命令
$> ipython [-i] script.py script2.py ...
$> python [-i] script.py script2.py ...
行为与命令完全相同
$> ipython [-i] script.py script2.py ...
$> python [-i] script.py script2.py ...
在这种情况下,运行script.py,其中的sys.argv
为['script.py','script2.py','…']
,
如果指定了
-i
,它将在运行脚本后进入交互式会话。我可以确认这是一个错误,因此这不是用户的误解。我认为可能是文档有问题。它不会(现在?)运行所有文件,但其行为与您调用的python args
类似。因此,如果foo.py查看sys.argv
,它将看到bar.py作为命令行参数列出。