Do you mean, all you want is "addpath(dirname) = push!(LOAD_PATH, dirname)"?
Or something different?
As a convert from Matlab, the first thing I asked for when shopping around for an alternative language for scientific computing was "what's the command I use to run a file, top to bottom".
From my view, this is a important command to have front and center. I would want to avoid forcing newbies to use "require"... for example just by looking at the help documentation I knew there would be some spurious behavior I didn't understand...
julia> ?require
Loading help data...
Base.require(file::String...)
Load source files once, in the context of the "Main" module, on
every active node, searching the system-wide "LOAD_PATH" for
files. "require" is considered a top-level operation, so it sets
the current "include" path but does not use it to search for
files (see help for "include"). This function is typically used
to load library code, and is implicitly called by "using" to load
packages.
Just my two cents.
Cheers,
Ethan
The %run magic command allows you to run any python script and load all of its data directly into the interactive namespace. Since the file is re-read from disk each time, changes you make to it are reflected immediately (unlike imported modules, which have to be specifically reloaded). IPython also includes dreload, a recursive reload function.
%run has special flags for timing the execution of your scripts (-t), or for running them under the control of either Python’s pdb debugger (-d) or profiler (-p).
function runfile(file::String)
flag = true # changes to false if the file is found
for dir in [pwd(), LOAD_PATH...]
dfile = joinpath(dir,file)
if isfile(dfile)
include_string(readall(dfile))
flag = false
break
end
end
if flag error("Error: could not open $file") end
end
This works right? Am I missing anything subtle about it's behavior? In particular, I want it to work like "include" but checks LOAD_PATH if it can't find the file in the working directy?
Cheers,
Ethan