# Importing symbols from submodule

**URL:** <https://discourse.julialang.org/t/importing-symbols-from-submodule/97488>\
**Category:** General Usage\
**Tags:** question, modules\
**Created:** [April 14, 2023, 7:28pm UTC](https://discourse.julialang.org/t/importing-symbols-from-submodule/97488 "2023-04-14T19:28:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jlapeyre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jlapeyre/32/4514_2.png) [@jlapeyre](https://discourse.julialang.org/u/jlapeyre)\
**Post date:** [April 14, 2023, 7:28pm UTC](https://discourse.julialang.org/t/importing-symbols-from-submodule/97488/1 "2023-04-14T19:28:40Z")

</div>

I’d like to import symbols from a submodule without fully qualifying the module. Like this

```julia
import TestPackage.InnerMod
import InnerMod: inner_a # or import InnerMod.a

```

But that gives me `ArgumentError: Package InnerMod not found in current path`  
Note that `import TestPackage.InnerMod: inner_a` works. But in some situations this can be quite verbose.

The following also fails.

```julia
import TestPackage as TP
import TP.InnerMod: inner_a # fails
import TP.InnerMod.inner_a # fails

```

The alias TP is not a perfect standin for the full name.

I suppose I could write a macro. Maybe there is already a package to do this?  
By the way, splitting the package into separate packages is not a good option in the cases I am thinking of.

Here is the file I used to do the tests above:

```julia
module TestPackage
module InnerMod
const inner_a = 2
end # module InnerMod
end # module TestPackage

```

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [April 14, 2023, 7:32pm UTC](https://discourse.julialang.org/t/importing-symbols-from-submodule/97488/2 "2023-04-14T19:32:13Z")

</div>

> [@jlapeyre](#):
>
> ```julia
> module TestPackage
> module InnerMod
> const inner_a = 2
> end # module InnerMod
> end # module TestPackage
> 
> ```

I think you need a dot there:

```julia
julia> module TestPackage
       module InnerMod
       const inner_a = 2
       end # module InnerMod
       import .InnerMod: inner_a # note the dot
       end # module TestPackage

julia> TestPackage.inner_a
2

```

---

<div class="post-metadata">

**Author:** ![jlapeyre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jlapeyre/32/4514_2.png) [@jlapeyre](https://discourse.julialang.org/u/jlapeyre)\
**Post date:** [April 14, 2023, 7:39pm UTC](https://discourse.julialang.org/t/importing-symbols-from-submodule/97488/3 "2023-04-14T19:39:25Z")

</div>

That’s it!
