Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Content of an imported module in Julia

Tags:

julia

Suppose I am using/importing a module in Julia:

using someModule

I didn't write the module and I would like to know what functions,variables,types, etc. are in the export line of that module. How van I do that? (I'm using Julia 1.3.1)

like image 800
Pitt Prog Avatar asked Mar 25 '20 18:03

Pitt Prog


People also ask

What is the difference between import and using in Julia?

My guess based on reading the docs: using is used to bring another module into the name-space of the current module. import is used to bring specific types/functions/variables from other modules into the name-space of the current module.

Where does Julia look for modules?

Julia looks for module files in directories defined in the LOAD_PATH variable. And, since you don't want to do this every single time you run Julia, put this line into your startup file ~/. julia/config/startup. jl , which runs each time you start an interactive Julia session.

What does Julia include?

Julia has two mechanisms for loading code: Code inclusion: e.g. include("source. jl") . Inclusion allows you to split a single program across multiple source files.

How do I import a module into Julia?

To load a module from a package, the statement using ModuleName can be used. To load a module from a locally defined module, a dot needs to be added before the module name like using . ModuleName .


1 Answers

The names function will list all names exported by the given module. For example:

julia> using Statistics

julia> names(Statistics)
14-element Array{Symbol,1}:
 :Statistics
 :cor
 :cov
 :mean
 :mean!
 :median
 :median!
 :middle
 :quantile
 :quantile!
 :std
 :stdm
 :var
 :varm


like image 80
François Févotte Avatar answered Oct 06 '22 11:10

François Févotte