# Get module source

**URL:** <https://forum.inductiveautomation.com/t/get-module-source/59449>\
**Category:** Ignition\
**Created:** [May 11, 2022, 12:30pm UTC](https://forum.inductiveautomation.com/t/get-module-source/59449 "2022-05-11T12:30:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [May 11, 2022, 12:30pm UTC](https://forum.inductiveautomation.com/t/get-module-source/59449/1 "2022-05-11T12:30:44Z")

</div>

Hello folks,

For (insert whatever reasons) purposes, I’m trying to get the source code of a custom module.  
For any other module, I could just import it and use `inspect.getsource(module)`, but it doesn’t work for home made ones. Because they’re not basic modules:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/4/74e0798ffb62b4be3df009e7d43cc759d73f2052.png)

Any idea how I could work around that ?

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [May 11, 2022, 12:37pm UTC](https://forum.inductiveautomation.com/t/get-module-source/59449/2 "2022-05-11T12:37:07Z")

</div>

Hey I think I got it, I may have asked too soon:

```python
print(module.code)

```

seems to print the actual module’s code.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [May 11, 2022, 12:51pm UTC](https://forum.inductiveautomation.com/t/get-module-source/59449/3 "2022-05-11T12:51:30Z")

</div>

Note that `foo.code` seems to fail if `foo` contains `from bar import *`, in which case it returns the code from `bar` instead.
