#1
|
|||
|
|||
Python 3 - importing local modules
Hey all,
I'm trying to make a script I wrote in Python 3 to be more modular - i.e. I want to store some of my functions in a separate file. For instance: Code:
def find_prompt(): screenrow = crt.Screen.CurrentRow x = crt.Screen.Get(screenrow,1,screenrow,30).strip(" ") Code:
if 'crt' in globals(): script_dir, script_name = os.path.split(crt.ScriptFullName) if script_dir not in sys.path: sys.path.insert(0, script_dir) else: script_dir, script_name = os.path.split(os.path.realpath(__file__)) Thanks! Last edited by cboyack; 01-01-2021 at 11:42 AM. Reason: Please use the [CODE] and [/CODE] tags to denote a script |
#2
|
|||
|
|||
Hi garrettwilliams,
The code which you shared at the bottom of your post is a solution to a completely different problem. We have put together a set of instructions for importing custom modules referencing the crt object here. While the example on the referenced page is in python 2 (it hasn't yet been tested with python 3), the concept is the same. In the future, for better readability, please use the [CODE] and [/CODE] tags surrounding any code snippets you include, so that spacing and indentation will be visible.
__________________
Thanks, --Cameron VanDyke Software Technical Support support@vandyke.com (505) 332-5730 Last edited by jdev; 01-01-2021 at 01:48 PM. |
#3
|
|||
|
|||
Thanks! Extremely helpful.
|
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Display Modes | Rate This Thread |
|
|