In python you can do something like this to let you use a shortened module name:
>>> import tensorflow as tf
From then on you can refer to tf
, instead of having to type tensorflow
everywhere.
Is something like this possible in Juila?
In python you can do something like this to let you use a shortened module name:
>>> import tensorflow as tf
From then on you can refer to tf
, instead of having to type tensorflow
everywhere.
Is something like this possible in Juila?
Yep, you can just assign the module to a new name.
import JSON
const J = JSON
J.print(Dict("Hello, " => "World!"))
I highly recommend to use the const
because otherwise there will be a performance penalty. (With the const
, there is no performance penalty.)
I'm pushing the practical snippet @Alan don't mentioned:
MyMod.jl
:module MyModule
plus(x, y) = x + y
myfield = 0
end
Main.jl
:# Only if you're including the module from another file.
include("MyMod.jl")
import .MyModule as mymod
println(mymod.myfield)
println(mymod.plus(1, 1))
Main resources:
© 2022 - 2024 — McMap. All rights reserved.