# Calling a function from another notebook using \`my\_file.some\_function()\`

**URL:** https://discourse.julialang.org/t/calling-a-function-from-another-notebook-using-my-file-some-function/55806
**Category:** Jupyter-Notebook
**Tags:** jupyter
**Created:** [February 22, 2021, 9:24pm UTC](https://discourse.julialang.org/t/calling-a-function-from-another-notebook-using-my-file-some-function/55806 "2021-02-22T21:24:03Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Michael\_Barmann](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/michael_barmann/32/20389_2.png) [@Michael\_Barmann](https://discourse.julialang.org/u/Michael_Barmann)
#### Post date: [February 22, 2021, 9:24pm UTC](https://discourse.julialang.org/t/calling-a-function-from-another-notebook-using-my-file-some-function/55806/1 "2021-02-22T21:24:03Z")

</div>

Is there a way to use the dot syntax in Jupyter Notebook to call a function that was defined in a different notebook? For example, suppose I have a notebook “test.ipynb” containing a function called `square(x)`, and say we’ve imported test.ipynb using

```julia
using NBInclude
@nbinclude("test.ipynb")

```

Now that `test.ipynb` is imported, we can call `square()` just like a regular function, e.g. `square(x)`. But for bookkeeping purposes, I’d like to call `square` by referencing the notebook in which it was defined in, e.g. `test.square(x)`. Unfortunately I tried this and it didn’t work. Is there a similar way to do this?

---

<div class="post-metadata">

### Author: ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)
#### Post date: [February 22, 2021, 9:33pm UTC](https://discourse.julialang.org/t/calling-a-function-from-another-notebook-using-my-file-some-function/55806/2 "2021-02-22T21:33:54Z")

</div>

nope, in order for `test.square()` to work, `test` must be a module. NBInclude doesn’t create one for you. and honestly that sounds like a bad idea. NBInclude at the moment works exactly like an `include()` with all the cell content stitched together in plain text.

---

<div class="post-metadata">

### Author: ![Michael\_Barmann](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/michael_barmann/32/20389_2.png) [@Michael\_Barmann](https://discourse.julialang.org/u/Michael_Barmann)
#### Post date: [February 22, 2021, 9:57pm UTC](https://discourse.julialang.org/t/calling-a-function-from-another-notebook-using-my-file-some-function/55806/3 "2021-02-22T21:57:11Z")

</div>

Thanks for the answer. So I just have to create a module then…why would this be a bad idea?

---

<div class="post-metadata">

### Author: ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)
#### Post date: [February 22, 2021, 10:18pm UTC](https://discourse.julialang.org/t/calling-a-function-from-another-notebook-using-my-file-some-function/55806/4 "2021-02-22T22:18:38Z")

</div>

the idea of single file as module (“automatically”, without having `module end` inside that file) sounds bad to me.
