In Python, you can import a module with whatever name you want by using the as
keyword. Is there an equivalent to this in Julia?
Obviously you can just do
import moduleWithReallyLongName
M = moduleWithReallyLongName
Is there a better way?
import moduleWithReallyLongName
const M = moduleWithReallyLongName
Please note the usage of const. By a rule of thumb any global variable in Julia should be type stable, otherwise you will observe reduced performance.
Another option is the package ImportMacros.jl
(https://github.com/fredrikekre/ImportMacros.jl)
using ImportMacros
@import moduleWithReallyLongName as M
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