# Call functions with the same names from different files

**URL:** <https://discourse.julialang.org/t/call-functions-with-the-same-names-from-different-files/105987>\
**Category:** New to Julia\
**Created:** [November 9, 2023, 11:54am UTC](https://discourse.julialang.org/t/call-functions-with-the-same-names-from-different-files/105987 "2023-11-09T11:54:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dgsob](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dgsob/32/217317_2.png) [@dgsob](https://discourse.julialang.org/u/dgsob)\
**Post date:** [November 9, 2023, 11:54am UTC](https://discourse.julialang.org/t/call-functions-with-the-same-names-from-different-files/105987/1 "2023-11-09T11:54:01Z")

</div>

Hi,

I have a file where I include files:

```julia
include("./path/File1.jl")
include("./path/File2.jl")

```

and then I want to call functions from these files, and since they have the same name, i wanted to use the file’s names as discriminators:

```julia
File1.function()
File2.function()

```

These are my functions, so I can just change their names and it’ll be good, but is it possible to achieve what I’m trying to?

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [November 9, 2023, 11:57am UTC](https://discourse.julialang.org/t/call-functions-with-the-same-names-from-different-files/105987/2 "2023-11-09T11:57:38Z")

</div>

You are looking for Modules: [Modules · The Julia Language](https://docs.julialang.org/en/v1.9/manual/modules/)  
A distinction based on the source file name is not possible (AFAIK).

---

<div class="post-metadata">

**Author:** ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/27854_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)\
**Post date:** [November 9, 2023, 12:34pm UTC](https://discourse.julialang.org/t/call-functions-with-the-same-names-from-different-files/105987/3 "2023-11-09T12:34:31Z")

</div>

Conceptually, the `include` keyword just copy-pastes the code in the target file. Unlike Python’s `import`, it does not create a separate namespace (or module): in Julia, namespaces and files are disconnected.

If you really prefer Python-like behavior, take a look at [GitHub - Roger-luo/FromFile.jl: Julia enhancement proposal (Julep) for implicit per file module in Julia](https://github.com/Roger-luo/FromFile.jl)

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [November 9, 2023, 12:37pm UTC](https://discourse.julialang.org/t/call-functions-with-the-same-names-from-different-files/105987/4 "2023-11-09T12:37:43Z")

</div>

> [@oheil](#):
>
> You are looking for Modules: [Modules · The Julia Language](https://docs.julialang.org/en/v1.9/manual/modules/)

See also [Best practise: organising code in Julia - #2 by stevengj](https://discourse.julialang.org/t/best-practise-organising-code-in-julia/74362/2)

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [November 9, 2023, 12:47pm UTC](https://discourse.julialang.org/t/call-functions-with-the-same-names-from-different-files/105987/5 "2023-11-09T12:47:29Z")

</div>

You may be interested in [GitHub - Roger-luo/FromFile.jl: Julia enhancement proposal (Julep) for implicit per file module in Julia](https://github.com/Roger-luo/FromFile.jl)
