Skip to main content

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.3.tar.gz (2.6 kB view details)

Uploaded Source

File details

Details for the file importfa-0.3.tar.gz.

File metadata

  • Download URL: importfa-0.3.tar.gz
  • Upload date:
  • Size: 2.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.13

File hashes

Hashes for importfa-0.3.tar.gz
Algorithm Hash digest
SHA256 3dbd8794040db3ac0eb95e5ce1e62a895b4d5dc2a20eedb0daf3e4f7ce172233
MD5 e4c5fcd74be800f5fcd5ee5555ece9a9
BLAKE2b-256 2d0a6cadb779159bd5499485a2b29d89b2ba15a978e8da2804edd20520cae244

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page