# Splitting the code into modules

**URL:** https://discourse.slicer.org/t/splitting-the-code-into-modules/26409
**Category:** Support
**Created:** [November 23, 2022, 3:17pm UTC](https://discourse.slicer.org/t/splitting-the-code-into-modules/26409 "2022-11-23T15:17:58Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![S\_Arbabi](https://avatars.discourse-cdn.com/v4/letter/s/dfb087/32.png) [@S\_Arbabi](https://discourse.slicer.org/u/S_Arbabi)
#### Post date: [November 23, 2022, 3:17pm UTC](https://discourse.slicer.org/t/splitting-the-code-into-modules/26409/1 "2022-11-23T15:17:58Z")

</div>

Hi,

for the sake of improving readability I wanted to put some useful functions that I write and frequently call into another file.py and only import and use them inside the slicer module code (inside widget or logic).  
But for some reason it doesn’t work properly, and whenever I update the function in my file.py, I need to restart slicer so the slicer module can see and use the changes I made.  
Any ideas?

Best

---

<div class="post-metadata">

### Author: ![pll\_llq](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pll_llq/32/9408_2.png) [@pll\_llq](https://discourse.slicer.org/u/pll_llq)
#### Post date: [November 23, 2022, 9:30pm UTC](https://discourse.slicer.org/t/splitting-the-code-into-modules/26409/2 "2022-11-23T21:30:04Z")

</div>

If you have developer mode enabled and your module UI has the default ״Reload module” button- press it every time you edit your script so that only the module is reloaded and not the whole slicer.  
Hope this helps

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [November 23, 2022, 10:49pm UTC](https://discourse.slicer.org/t/splitting-the-code-into-modules/26409/3 "2022-11-23T22:49:06Z")

</div>

The reload button only knows about your module.py file. You need to add reloading of any additional files. See example in [SlicerHeart extension](https://github.com/SlicerHeart/SlicerHeart/blob/d5de4cb42c8cdda24eac430d096eddca5f14e8fd/ValveAnnulusAnalysis/ValveAnnulusAnalysis.py#L785-L798). Note that if you have a complex dependency between multiple files then you need to reload the files in the correct order (or else you may need to click reload a few times).
