mahiki / DesertIslandDisk

My general purpose utility set package for julia
MIT License
1 stars 0 forks source link

List currently defined variables in REPL #8

Open mahiki opened 1 month ago

mahiki commented 1 month ago

Kinda like dir() in python, its nice to just list the defined variables in the session so far. Not module ones, just Main, I think.

Good example implementation from Mustache.jl docs:

_names = String[]
_summaries = String[]
for s in sort(map(string, names(Main)))
    v = Symbol(s)
    if isdefined(Main,v)
        push!(_names, s)
        push!(_summaries, summary(eval(v)))
    end
end

using DataFrames
d = DataFrame(names=_names, summs=_summaries)

out = Mustache.render(tpl, TITLE="A quick table", D=d)
print(out)
mahiki commented 1 month ago
names(Main)                    # gives list of defined names
summary(<variable>)      # details of type definition