[IPython-user] run python script with arg
Fernando Perez
Fernando.Perez at colorado.edu
Fri Sep 24 12:43:12 CDT 2004
John Hunter schrieb:
>
> I am trying to use ipython to run a python script that takes command
> line args
>
> Eg, you can do
>
>
>>python somefile.py -C somearg
>
>
> When I run this with ipython, it appears that ipython is trying to
> process the -C flag, and is complaining about not knowing the flag.
That kind of processing from the command line is just not supported (I'd have
to be smarter than I am right now about splitting args for ipython and args
for the upcoming script). But you can definitely do the following:
planck[~/test]> ipython --nobanner
In [1]: cat argv.py
#!/usr/bin/env python
import sys
print 'argv:',sys.argv
In [2]: run argv.py -C somearg foo bar
argv: ['argv.py', '-C', 'somearg', 'foo', 'bar']
In practice, this should do what you want. It's an extra step (you need to
start ipython first and _then_ use run), but hopefully this is OK in your
context. Let me know if you need more details/help.
Best,
f
More information about the IPython-user
mailing list