# Appropriate Structures for Reusing Code

**URL:** <https://discourse.julialang.org/t/appropriate-structures-for-reusing-code/28871>\
**Category:** General Usage\
**Created:** [September 17, 2019, 11:26pm UTC](https://discourse.julialang.org/t/appropriate-structures-for-reusing-code/28871 "2019-09-17T23:26:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anodos](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/anodos/32/212778_2.png) [@anodos](https://discourse.julialang.org/u/anodos)\
**Post date:** [September 17, 2019, 11:26pm UTC](https://discourse.julialang.org/t/appropriate-structures-for-reusing-code/28871/1 "2019-09-17T23:26:50Z")

</div>

I’ve recently been forced to relearn python for a work application. Needless to say, after working with Julia for a while, there were plenty of things I found a little painful (vectorisation, the need to use numba/cython or even write in native C, etc.) However, one thing I did find helpful was how easy it was to _structure_ your code in python, in such a way that it could easily be _re-used_. The ability to write a module with a bunch of useful functions _once_ and then ever-after type “from xxx import yyy as zzz” is really nice.

Is there an equivalent structure in Julia, which can allow for easy reusability of key code?

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [September 17, 2019, 11:30pm UTC](https://discourse.julialang.org/t/appropriate-structures-for-reusing-code/28871/2 "2019-09-17T23:30:00Z")

</div>

Yes. There are modules, and they act the same way. Julia packages are just a module like this.

---

<div class="post-metadata">

**Author:** ![anon92994695](https://avatars.discourse-cdn.com/v4/letter/a/ce7236/32.png) [@anon92994695](https://discourse.julialang.org/u/anon92994695)\
**Post date:** [September 18, 2019, 12:29am UTC](https://discourse.julialang.org/t/appropriate-structures-for-reusing-code/28871/3 "2019-09-18T00:29:04Z")

</div>

Yea like Chris said you can make a package and import it([5. Creating Packages · Pkg.jl](https://julialang.github.io/Pkg.jl/v1/creating-packages/)),

Or if you’re hacking away prototyping you can also using  
`include("myawesomejuliascript.jl")`  
and it will run all the code in the specified file([Essentials · The Julia Language](https://docs.julialang.org/en/v1/base/base/#Base.include)).

---

<div class="post-metadata">

**Author:** ![anodos](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/anodos/32/212778_2.png) [@anodos](https://discourse.julialang.org/u/anodos)\
**Post date:** [September 18, 2019, 12:41am UTC](https://discourse.julialang.org/t/appropriate-structures-for-reusing-code/28871/4 "2019-09-18T00:41:47Z")

</div>

Well… that was simple. Thanks!

---

<div class="post-metadata">

**Author:** ![Raf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raf/32/3383_2.png) [@Raf](https://discourse.julialang.org/u/Raf)\
**Post date:** [September 18, 2019, 5:08am UTC](https://discourse.julialang.org/t/appropriate-structures-for-reusing-code/28871/5 "2019-09-18T05:08:34Z")

</div>

You’ll probably find this easier in Julia than python 🙂

There are also helpers like [GitHub - invenia/PkgTemplates.jl: Create new Julia packages, the easy way](https://github.com/invenia/PkgTemplates.jl) to auto generate the package structure with docs, Travis/appveyor testing and everything already set up.
