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.
Raw data
{
"_id": null,
"home_page": "https://github.com/wywzxxz/importfa",
"name": "importfa",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "sample setuptools development",
"author": "wywzxxz",
"author_email": "wywzxxz@163.com",
"download_url": null,
"platform": null,
"description": "Given an equivalent way to achieve this but in import style, prevent formatter smash up your code\n\n```\nimport xxx\nif __name__==\"__main__\":\n import os,sys\n fa = os.path.abspath(\"/\".join([sys.argv[0] + \"/..\"] + [\"..\"] * 2))\n sys.path.append(fa)\n\nimport xxx_local_package # similar to ..xxx\n```\n\nFor short, this project does this:\n\n| use this project | | equivalent code |\n| --- | --- | --- |\n| import importfa.f | \u2192 | os.path.append(sys.argv\\[0\\] + \"/../..\") |\n| import importfa.ff | \u2192 | os.path.append(sys.argv\\[0\\] + \"/../../..\") |\n| import importfa.fff | \u2192 | os.path.append(sys.argv\\[0\\] + \"/../../../..\") |\n| import importfa.fffff | \u2192 | os.path.append(sys.argv\\[0\\] + \"/../../../../..\") |\n\n\nFor convenience, `import importfa.f8` is equivalent to `importfa.ffffffff`,etc.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "add parent/ancestor folder path into sys.path when import",
"version": "0.4",
"project_urls": {
"Homepage": "https://github.com/wywzxxz/importfa"
},
"split_keywords": [
"sample",
"setuptools",
"development"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "a64ee64414cd90610b7a09037f88accac1cc48bc6299e40794ee83f0000cbb1c",
"md5": "767e07ab21204144a67be64555878ae5",
"sha256": "255cb2cd419f8ae5eda36fb8b2c50dc89487b107d02476ba5b9695cf874f8793"
},
"downloads": -1,
"filename": "importfa-0.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "767e07ab21204144a67be64555878ae5",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 4629,
"upload_time": "2024-11-01T23:57:34",
"upload_time_iso_8601": "2024-11-01T23:57:34.576509Z",
"url": "https://files.pythonhosted.org/packages/a6/4e/e64414cd90610b7a09037f88accac1cc48bc6299e40794ee83f0000cbb1c/importfa-0.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-01 23:57:34",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "wywzxxz",
"github_project": "importfa",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "importfa"
}