python - Running a script in IPython with input from a file -


i have python script, purpose of question can reduced to:

import sys data = sys.stdin.read() # data ... 

the idea run script shell as

python my_script.py < datafile 

now i'd call script ipython using run command , tried following:

in [1]: run my_script.py < datafile 

but apparently doesn't read datafile, , still waits user input on ipython terminal.

how can have run command read standard input file instead of terminal? checked documentation of run command, doesn`t contain pointers.

i'm looking answers can access variables defined in script (data in example here) ipython terminal after having called script.

one solution execute script way:

in [1]: !python my_script.py < datafile 

obviously, works around run command, allows execute script within ipython.


Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

jquery - How would i go about shortening this code? And to cancel the previous click on click of new section? -