Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Module aliasing in Julia

Tags:

module

julia

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?

like image 218
aneccodeal Avatar asked Feb 08 '17 03:02

aneccodeal


2 Answers

Julia now supports renaming with as.

like image 78
Alan Avatar answered Oct 06 '22 08:10

Alan


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.)

like image 45
Fengyang Wang Avatar answered Oct 06 '22 06:10

Fengyang Wang