I think I discovered a bug in how %run works with argv. %run will expand glob patterns even when quoted.
Demo:
First, in terminal:
$ touch foo.txt
$ touch bar.txt
Then make the program demo.py:
import sys
print(sys.argv[1:])
From the command line:
$ python demo.py *.txt
['bar.txt', 'foo.txt']
$ python demo.py "*.txt"
['*.txt']
This is ad you'd expect.
From iPython:
In [1]: %run demo.py *.txt
['foo.txt', 'bar.txt']
In [2]: %run demo.py "*.txt"
['foo.txt', 'bar.txt']
The latter should not be expanded!
Versions
I didn't have time to test this on multiple platforms but this was on macOS Catalina with Anaconda Python:
Python 3.8.3 (default, Jul 2 2020, 11:26:31)
IPython 7.16.1 -- An enhanced Interactive Python. Type '?' for help.
Thanks!
I think I discovered a bug in how
%runworks with argv.%runwill expand glob patterns even when quoted.Demo:
First, in terminal:
Then make the program
demo.py:From the command line:
This is ad you'd expect.
From iPython:
The latter should not be expanded!
Versions
I didn't have time to test this on multiple platforms but this was on macOS Catalina with Anaconda Python:
Thanks!