In python to get the documentation of a function, we can type (for example) help(len)
.
How to do the same to get a function's documentation in Julia?
entered help mode when at the beginning of the line, a semicolon ( ; ) will enter the shell mode. And it can be exited by pressing backspace at the beginning of the line. For Windows users, Julia's shell mode does not expose windows shell commands.
REPL stands for read, execute, print, loop. Once Julia is installed, typing Julia at the command line opens the REPL. The REPL has many features that can help you test snippets and debug your code.
Open the command pallette (Ctrl + Shift + P) and start typing “Julia: Execute File in REPL” until you can autocomplete it.
In Julia you can use a question mark followed by a function name, i.e. ?functionname
, to get information about a function.
If you are using the REPL, the question mark will switch your julia>
prompt to a help?>
prompt - similar to how ]
triggers the pkg>
REPL mode. Check out the documentation for more information.
In Jupyter notebooks (IJulia) you just type ?println
and there is no visible REPL mode change.
Example:
help?> println # I typed ?println
search: println printstyled print sprint isprint
println([io::IO], xs...)
Print (using print) xs followed by a newline. If io is not supplied, prints to stdout.
Examples
≡≡≡≡≡≡≡≡≡≡
julia> println("Hello, world")
Hello, world
julia> io = IOBuffer();
julia> println(io, "Hello, world")
julia> String(take!(io))
"Hello, world\n"
Note that this approach isn't restricted to functions. It works for all objects that have some docstrings attached to them:
help?> Sys.CPU_THREADS # docstring of a constant
Sys.CPU_THREADS
The number of logical CPU cores available in the system, i.e. the number of threads that the CPU can run concurrently. Note that this is not necessarily the number of CPU cores, for example, in the presence of hyper-threading (https://en.wikipedia.org/wiki/Hyper-threading).
See Hwloc.jl or CpuId.jl for extended information, including number of physical cores.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With