In ipython (0.10.2), I’d like to run with bash shell style (or glob.glob) expansion. I’d like to do something like these and have the arguments expand out just as they would if I were in bash. Is this possible?
filenames = !ls *.sbet
run sbet.py $filenames
# fails because filenames is a list
# or the simpler case:
run sbet.py *.sbet
# failes with "*.sbet" being directly passed in without being expanded.
Suggestions? Thanks!
The return of
filenames = !ls *.sbetis a special list, with a few extra attributes:filenames.l– the listfilenames.s– a whitespace-separated stringfilenames.n– a newline-separated stringdo
filenames?in IPython for more info.So to pass the args to run, you want
filenames.s:If you have a regular list, then you will need to turn it into a string yourself, before passing to run:
You might make a feature request for automatic expansion of file globs when passed to
%runifrun foo.py *.sbetis valuable to you.