I did it like this, outside of module Matematicas: https://github.com/Ismael-VC/Club_TESCI/blob/master/CODIGO/julia_code/Matematicas.jl
to emulate Python's construct: if __name__ == '__main__': pass Running from the command line works: ismaelvc@toybox ~/T/C/C/julia_code (master)> julia Matematicas.jl Test: Main fgen(4, 3, -1) x1 = 0.25 x2 = -1.0 Control TEST! While importing in the REPL: julia> import Matematicas Control TEST! julia> While using: julia> using Matematicas Control TEST! julia> While using requie: julia> require("Matematicas.jl") Control TEST! julia> While including: julia> include("Matematicas.jl") Control TEST! julia> But the code inside: if !isinteractive() && current_module() == Main # ...test... end is still run when it is imported from another file! How can I avoid this? Modules work very different thatn what I'm used to in Python, but this construct behaviour is very handy and I'd like to keep using it in Julia: ismaelvc@toybox ~/T/C/C/julia_code (master)> cat > import_test.jl import Matematicas ismaelvc@toybox ~/T/C/C/julia_code (master)> julia import_test.jl Test: Main fgen(4, 3, -1) x1 = 0.25 x2 = -1.0 Control TEST! ismaelvc@toybox ~/T/C/C/julia_code (master)> cat > require_test.jl require("Matematicas.jl") ismaelvc@toybox ~/T/C/C/julia_code (master)> julia require_test.jl Test: Main fgen(4, 3, -1) x1 = 0.25 x2 = -1.0 Control TEST! ismaelvc@toybox ~/T/C/C/julia_code (master)> cat > using_test.jl using Matematicas ismaelvc@toybox ~/T/C/C/julia_code (master)> julia using_test.jl Test: Main fgen(4, 3, -1) x1 = 0.25 x2 = -1.0 Control TEST! ismaelvc@toybox ~/T/C/C/julia_code (master)> cat > include_test.jl include("Matematicas.jl") ismaelvc@toybox ~/T/C/C/julia_code (master)> julia include_test.jl Test: Main fgen(4, 3, -1) x1 = 0.25 x2 = -1.0 Control TEST!