>From https://groups.google.com/d/topic/julia-users/AWCerAdDLQo/discussion :
eval(Expr(:using,:PyPlot)) can be used inside a conditional. --Peter On Friday, August 22, 2014 8:56:53 AM UTC-7, Spencer Lyon wrote: > > I am working on a library that defines various types as well as a few > “helper” functions to plot those types with PyPlot. > > If I do [import|using] PyPlot at the top level of any file in my package, > PyPlot is loaded when I do [using|import] MyPackage. This makes the > startup time for my package much much longer. > > What I would like to do is instead of having to load it when my package > loads, I could load it when someone calls one of the functions that needs > it. > > Here is an example of what I would like to do: > > function plot_my_type(x::MyType) > if !isdefined(:PyPlot) > using PyPlot > end > # finish the function by plotting with PyPlot > end > > I haven’t been able to get a solution that works for this. Does anyone > know if it is possible? > >
