autocomplete for custom module?
OK, so simple question but can't seem to find much help on the subject: is there a way to use the IDE's autocomplete for a custom module? The lab has a bunch of very commonly used utility functions and we have new people writing scripts every academic year. Would be very handy to be able to have autocomplete to facilitate training!
|
After importing the module into your script, the autocomplete should display the function names. Is the module in the same folder as the script or a different location?
|
Thanks! So, after your comment I confirmed that it works if the module is in the current directory of the script I'm working on. Very cool!
But, as you suspected, I have it setup as a package in a different directory (including __init__.py). I have added the path to the enclosing folder with sys.path.insert, but it still doesn't work.. ? |
Can you post the code you are using to import the file including any path related commands?
|
Sure!
Directory structure is set up like this: Code:
FIVEL/ top-level enclosing folder Code:
import sys thanks! |
It does not look like the autocomplete is set to work with paths added on the fly using the sys.path.insert command. It may work by adding to the PYTHONPATH environment variable.
If the module is in a directory above you could use the following code to import the module. I just tested and this worked for me with the autocomplete: Code:
# import module in directory above |
The workaround worked for me too. Thanks for checking on that!
|
oops just kidding.. the workaround code makes autocomplete work(ish) but throws an error on execution
ValueError: Attempted relative import in non-package |
All times are GMT -7. The time now is 02:30 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC