# Get Qualified Path to Function in Shared Scripts

**URL:** <https://forum.inductiveautomation.com/t/get-qualified-path-to-function-in-shared-scripts/37122>\
**Category:** Ignition\
**Tags:** ignition79, scripting\
**Created:** [July 27, 2020, 4:15pm UTC](https://forum.inductiveautomation.com/t/get-qualified-path-to-function-in-shared-scripts/37122 "2020-07-27T16:15:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cmaynes](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmaynes/32/6852_2.png) [@cmaynes](https://forum.inductiveautomation.com/u/cmaynes)\
**Post date:** [July 27, 2020, 4:15pm UTC](https://forum.inductiveautomation.com/t/get-qualified-path-to-function-in-shared-scripts/37122/1 "2020-07-27T16:15:07Z")

</div>

How do you get the qualified path to a function?

```auto
ex:
my ignition structure is...

shared/
    outer_mod/
         inner_mod/
             func()

qualified path should be...

shared.outer_mod.inner_mod.func

```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [July 27, 2020, 4:34pm UTC](https://forum.inductiveautomation.com/t/get-qualified-path-to-function-in-shared-scripts/37122/2 "2020-07-27T16:34:19Z")

</div>

Starting with `func`? I don’t think you can. Functions are first-class objects in python, and don’t have any knowledge of the dictionaries/ mappings in which they are placed.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [July 27, 2020, 4:35pm UTC](https://forum.inductiveautomation.com/t/get-qualified-path-to-function-in-shared-scripts/37122/3 "2020-07-27T16:35:57Z")

</div>

Well, you can get their closure chain, i think, but that will only get you their script, not any outer modules.

---

<div class="post-metadata">

**Author:** ![cmaynes](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmaynes/32/6852_2.png) [@cmaynes](https://forum.inductiveautomation.com/u/cmaynes)\
**Post date:** [July 27, 2020, 5:20pm UTC](https://forum.inductiveautomation.com/t/get-qualified-path-to-function-in-shared-scripts/37122/4 "2020-07-27T17:20:29Z")

</div>

This is hacky, but the following works…

```auto
def func_qpath(func):
	mqpath = func.func_code.co_filename.split(':', 1)[1].rsplit('>', 1)[0]
	if hasattr(func, 'im_self'):
		mqpath += '.' + func.im_self. __name__
	return '.'.join((mqpath, func. __name__ ))

```

co\_filename would return ‘\<module:shared.outer\_mod.inner\_mod\>’, so it just needs to be parsed.

UPDATE:  
Added check for im\_self to see if method is part of a class. Note that this will fail if you have nested classes as it would only show the innermost class in the path.

```auto
ex:

class A(object):
    class B(object):
        def func(self):
            pass

path would be...

shared.outer_mod.inner_mod.B.func

```
