jehoshua Wrote:Thanks. I like the file structure and the class methods. If I wanted to use the class in other Python scripts and the file was called myPath.py , is it simply a matter of including: [from MyPaths import MyPaths]Almost that simple:
or do I have to setup something like a library ?
here's a new project example you can try (Linux, windows may be somewhat different):
- Create a directory named whatever your project name is
- cd to that directory
- Create a virtual environment with [python -m venv venv]
- Activate the virtual environment with (for Linux, windows different) [. ./venv/bin/activate]
- make a directory named [src]
- copy MyPaths.py to the new src directory
- [cd src]
- run MyPaths.py with command [python MyPaths.py]
- All paths will be created, ready to use. You will also have a virtual environment for your project
Note: You can eliminate steps 7 and 8 as this will happen the first time MyPaths in imported into any of your scripts. I haven't tested outside of virtual environment, as, frankly, I always use a virtual environment ofr any new project, but this should work without.