add parent/ancestor folder path into sys.path when import
Project description
Given an equivalent way to achieve this but in import style, prevent formatter smash up your code
import xxx
if __name__=="__main__":
import os,sys
fa = os.path.abspath("/".join([sys.argv[0] + "/.."] + [".."] * 2))
sys.path.append(fa)
import xxx_local_package # similar to ..xxx
For short, this project does this:
| use this project | equivalent code | |
|---|---|---|
| import importfa.f | → | os.path.append(sys.argv[0] + "/../..") |
| import importfa.ff | → | os.path.append(sys.argv[0] + "/../../..") |
| import importfa.fff | → | os.path.append(sys.argv[0] + "/../../../..") |
| import importfa.fffff | → | os.path.append(sys.argv[0] + "/../../../../..") |
For convenience, import importfa.f8 is equivalent to importfa.ffffffff,etc.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
importfa-0.5.tar.gz
(2.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file importfa-0.5.tar.gz.
File metadata
- Download URL: importfa-0.5.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb0ee27adcdf97b55a79c611076f7adeb38ffefdd27267d5f5f2195717679ce0
|
|
| MD5 |
f567cc1626d3204363200cb4b90266a0
|
|
| BLAKE2b-256 |
ce41ebf7530738bf2fdf2e5ef64e086c2236d1fc5721c5c03a99287e473f1d90
|
File details
Details for the file importfa-0.5-py3-none-any.whl.
File metadata
- Download URL: importfa-0.5-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
adba7b0527b19458578a23bccca996e14b37dd7d7d48cc8ae7afb2c79ed12ca7
|
|
| MD5 |
ffb5b643ffe4a44793acb2565b508e00
|
|
| BLAKE2b-256 |
98f08770295188e1361a5befa2c4cb0f4c9c9557250e60b40d737a337ba6d997
|