I am trying to provide a convenience function for the users of my package that launchs Jupyter notebook examples from the command line without depending on IJulia:
module Foo
# ...
function examples()
using IJulia
notebook(dir=joinpath(@__DIR__,"examples"))
end
end
The user would then launch the examples with “Foo.examples()” from the Julia prompt. The code above doesn’t work because we are not allowed to have using statements inside of functions. Is there any solution around this?
I believe that we would benefit from having reproducible examples in Julia packages via a standardized process. Is there anything happening with this regards already?
Thank you @mauro3. I am getting a strange error message now saying that notebook() is not a valid method:
ERROR: MethodError: no method matching notebook()
The applicable method may be too new: running in world age 21816, while current world is 21820.
Closest candidates are:
notebook(; dir, detached) at /home/juliohm/.julia/v0.6/IJulia/src/IJulia.jl:104 (method too new to be called from this world context.)
Yeah depends whether you intend to write the code down in a .jl file that users will include, or as an example that they will copy-paste in the REPL. I think @__DIR__ was changed recently to behave as pwd() when used in the REPL, but that’s not exactly what you want for copy-pasted code.
@PetrKryslUCSD, I don’t want to depend on IJulia, that is why we delay the evaluation inside of the function. So everyone that needs to run the examples, will install IJulia.