[Guido] > #!/usr/bin/env python > import sys, imp > fn = imp.find_module(sys.argv[1])[1] > del sys.argv[0] > sys.argv[0] = fn > execfile(fn) > > seems do the trick (though it could use nicer error handling). > > Wouldn't it be easier to add *this* to the Tools/scripts directory Though not as clean as -m, this script helps. For my own insufficiently advanced windows box, I added a launcher batch file, pythonm.bat: @python \py24\tools\scripts\runpy.py %1 %2 %3 %4 %5 %6 %7 %8 %9 It runs pretty well: C:\tmp> pythonm timeit -s "a=range(20)" "a.append(1)" "a.pop()" 100000 loops, best of 3: 1.75 usec per loop C:\tmp> pythonm regrtest test_string test_string 1 test OK. The combination of batch file and run.py isn't as good as the -m option, but it works and mostly meets my needs. The batch file is rather dumb, doesn't work with other python command line options, and won't work pipes. > Why does every handy thing that anyone ever thought of > have to be a Python command line option? Could Nick's idea be done without an -m option? If a user types, "python abc.py" and "abc.py" is not found, before aborting, try looking for it on sys.path. Raymond
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4