Is it possible to access the variables in __init__.py from the modules in the same package?

前端 未结 4 614
情话喂你
情话喂你 2021-02-07 01:41

I have a hello1 package that contains good.py module.

hello1
├── __init__.py
└── good.py

The init module has a variable

4条回答
  •  忘了有多久
    2021-02-07 02:02

    If you don't like sys.path.append(...) you could run your script as

    python -m hello1.good
    

    in the directory containing the "hello1"-directory or use the PYTHONPATH environment variable instead of sys.path.

提交回复
热议问题