# Best way of \`using\` without bring names into scope?

**URL:** <https://discourse.julialang.org/t/best-way-of-using-without-bring-names-into-scope/44272>\
**Category:** General Usage\
**Tags:** question, module\
**Created:** [August 4, 2020, 4:24pm UTC](https://discourse.julialang.org/t/best-way-of-using-without-bring-names-into-scope/44272 "2020-08-04T16:24:58Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![afbarnard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/afbarnard/32/16869_2.png) [@afbarnard](https://discourse.julialang.org/u/afbarnard)\
**Post date:** [August 4, 2020, 4:24pm UTC](https://discourse.julialang.org/t/best-way-of-using-without-bring-names-into-scope/44272/1 "2020-08-04T16:24:58Z")

</div>

Is there a way to use a module without bringing its names into scope? I don’t need to extend any methods.

Specifically, `using A` brings type `Foo` into scope, but other code already defines `Foo`, so there is a name ambiguity and I actually don’t need `A.Foo`. I know I could do `using A: x, y, z`, but I’d rather just do `A.x` where needed because I don’t need much from `A`. The [Summary of module usage](https://docs.julialang.org/en/v1/manual/modules/#Summary-of-module-usage-1) makes it look like there’s no way to do what I want. For now I’m doing `import A`, but I don’t need to extend any methods, so that seems like a misuse. What’s the best way to do a Pythonic `import`? TIA.

---

<div class="post-metadata">

**Author:** ![tomerarnon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomerarnon/32/3170_2.png) [@tomerarnon](https://discourse.julialang.org/u/tomerarnon)\
**Post date:** [August 4, 2020, 4:34pm UTC](https://discourse.julialang.org/t/best-way-of-using-without-bring-names-into-scope/44272/2 "2020-08-04T16:34:02Z")

</div>

You’re looking for `import` after all. Doing `import A` doesn’t let you extend the names of `A`. Only `import A: some_name` lets you do that.

---

<div class="post-metadata">

**Author:** ![afbarnard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/afbarnard/32/16869_2.png) [@afbarnard](https://discourse.julialang.org/u/afbarnard)\
**Post date:** [August 4, 2020, 4:36pm UTC](https://discourse.julialang.org/t/best-way-of-using-without-bring-names-into-scope/44272/3 "2020-08-04T16:36:34Z")

</div>

I thought that `import A` still allows me to extend methods in `A` but only if I qualify them like `A.x(y) = ...`. At least that’s what the [Summary of module usage](https://docs.julialang.org/en/v1/manual/modules/#Summary-of-module-usage-1) implies.

---

<div class="post-metadata">

**Author:** ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)\
**Post date:** [August 4, 2020, 4:37pm UTC](https://discourse.julialang.org/t/best-way-of-using-without-bring-names-into-scope/44272/4 "2020-08-04T16:37:53Z")

</div>

You can also do `using A: A`

I find that construction useful when I want to be able to access `foo` from module `A` without pulling in the rest of its symbols, but I still want to be able to do `A.bar()`.

For example:

```julia
using A: foo, A

foo() 
A.bar()  

```

---

<div class="post-metadata">

**Author:** ![afbarnard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/afbarnard/32/16869_2.png) [@afbarnard](https://discourse.julialang.org/u/afbarnard)\
**Post date:** [August 4, 2020, 4:40pm UTC](https://discourse.julialang.org/t/best-way-of-using-without-bring-names-into-scope/44272/5 "2020-08-04T16:40:22Z")

</div>

Wow, that’s counterintuitive! But that’s exactly what I’m trying to do. Thanks!

---

<div class="post-metadata">

**Author:** ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)\
**Post date:** [August 4, 2020, 4:45pm UTC](https://discourse.julialang.org/t/best-way-of-using-without-bring-names-into-scope/44272/6 "2020-08-04T16:45:07Z")

</div>

No that has nothing to do with import. You can do that with using too. If the module is the only thing you need , just import, it’s the standard and most readable way.

---

<div class="post-metadata">

**Author:** ![afbarnard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/afbarnard/32/16869_2.png) [@afbarnard](https://discourse.julialang.org/u/afbarnard)\
**Post date:** [August 4, 2020, 4:46pm UTC](https://discourse.julialang.org/t/best-way-of-using-without-bring-names-into-scope/44272/7 "2020-08-04T16:46:48Z")

</div>

Sorry, but what has nothing to do with import? Whether method extension is possible?

---

<div class="post-metadata">

**Author:** ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)\
**Post date:** [August 4, 2020, 4:54pm UTC](https://discourse.julialang.org/t/best-way-of-using-without-bring-names-into-scope/44272/8 "2020-08-04T16:54:16Z")

</div>

Correct. As long as you have module `M`, you can always extend a function `func` in it with `M.func`. It doesn’t matter how you get the module. It can be `import`ed, `using`ed, simply assigned as in `M = ...`.
