The magic of %run has the file_finder parameter, which is used to get the full path to the executable file (see here ); as you noticed, it just looks in the current directory, adding ".py" if necessary.
There seems to be no way to indicate which file finder to use from the magic of %run , but you have nothing to stop you from defining your own magic command, which calls %run using the appropriate file search.
As a very nasty hack, you can override the standard file_finder with file_finder :
IPython.core.magics.execution.ExecutionMagics.run.im_func.func_defaults[2] = my_file_finder
Honestly, with a change to the IPython API, which is likely to continue to work as a definition of your own magic.
ecatmur Jul 31 '12 at 18:13 2012-07-31 18:13
source share