List of loaded/imported packages in Julia
Use names
, e.g.
julia> using JuMP
julia> using Gurobi
julia> names(Main)
13-element Array{Symbol,1}:
:Calculus
:ans
:JuMP
:DualNumbers
:Graphs
:DataStructures
:ReverseDiffSparse
:MathProgSolverInterface
:Base
:MathProgBase
:Core
:Gurobi
:Main
using Lazy
children(m::Module) =
@>> names(m, true) map(x->m.(x)) filter(x->isa(x, Module) && x ≠ m)
children(Main)
will then give you a list of modules currently loaded.
Edit: I used Lazy.jl here for the thrush macro (@>>
), but you can rewrite it without easily enough:
children(m::Module) =
filter(x->isa(x, Module) && x ≠ m, map(x->m.(x), names(m, true)))
Alternatively you could add && x ≠ Lazy
to the filter
to avoid including it.
The proposed answers do not work with Julia 1.0 and hence here is a Julia 1.0 version:
filter((x) -> typeof(eval(x)) <: Module && x ≠ :Main, names(Main,imported=true))