DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Diadem with Python: Imported Function Library Codecompletion, Docstrings

Solved!
Go to solution

Hi everyone,

I'm looking for a way to enable the display of function docstrings and autocompletion when importing a custom Python library. Currently, all our functions, classes, and other components are placed in a single file, which makes the docstrings visible but can get quite messy over time.

I've tried creating a package and installing it into the site-packages folder, but that hasn't been successful. Meanwhile, external packages like "os" work perfectly fine with docstrings and autocompletion. Any suggestions on how to achieve this for custom libraries would be greatly appreciated.

 

 

 

0 Kudos
Message 1 of 6
(1,625 Views)

Hi dm999,
you just need to copy the Python scripts directly to the Python/Lib directory, then autocompletion and docstrings should work.
You may have to restart DIAdem if modules with the same name have already been used.

 

0 Kudos
Message 2 of 6
(1,560 Views)

Hi DIAdemo,

unfortuneatly this doesnt seem to work in my case. I copied the library in the directory you mentioned. I tried as package and just as file. I can access all the function, classes but still no docstrings, autocomplete etc.. i am working on the latest version (

DIAdem 2023 Q2).

dm999_0-1684222258107.png

dm999_1-1684222519761.png

 

 

 

0 Kudos
Message 3 of 6
(1,545 Views)
Solution
Accepted by topic author dm999

Hi dm999,
I see the .py files are not directly in the lib directory but in a subdirectory.

Then the main file must be named "__init__.py".

 

Message 4 of 6
(1,515 Views)

Hi,
in the folder it is structured like this:

dm999_0-1684763204064.png

with this __init__.py

dm999_1-1684763239869.png


i also tried to import a file directly from the Lib directory

dm999_2-1684763325743.png

this is how i import the two libraries

dm999_4-1684763582849.png

 

 

0 Kudos
Message 5 of 6
(1,499 Views)

Hi,

got it to work now. Copied everything in the __init__.py. Good enough for now, but i still think this shouldnt be the final solution.

 

thank you very much DIAdemo

 

0 Kudos
Message 6 of 6
(1,488 Views)