How can I avoid writing the whole module path of a function/type in a submodule when I want to use it in my module?
julia> using WriteVTK.VTKCellTypes
julia> VTKCellType
ERROR: UndefVarError: VTKCellType not defined
julia> WriteVTK.VTKCellTypes.VTKCellType
WriteVTK.VTKCellTypes.VTKCellType
Do you mean export
?
julia> module Foo
module Bar
export VTK
struct VTK end
end
end
Foo
julia> using Foo.Bar
julia> VTK
Foo.Bar.VTK
1 Like
Well, I am not the one who wrote the original module, so ideally I want to just use the submodule, which doesn’t have export in it. I could copy and paste the file and modify it in my program, but I don’t want to take credit for that code.
Looks like there is an export
in the original code (alternatively you could “fork” the repository and still retain original credits).
https://github.com/jipolanco/WriteVTK.jl/blob/master/src/WriteVTK.jl
Try something like:
import WriteVTK: VTKCellTypes
or if you want all exported function/types than use:
importall WriteVTK
Edited to Add: Actually, you should just be able to say using WriteVTK
and everything that is exported should be available (which includes VTKCellTypes
and VTKCellType
).
ETA2: Just tried this on my machine and it doesn’t work. WriteVTK
has an export VTKCellType
statement but that type is never defined in that module. It honestly seems like that the behavior that you’re looking for is the expected behavior… maybe open a Pull Request or Issue on github?
1 Like