accessing “module scope” vars

前端 未结 4 1446
醉酒成梦
醉酒成梦 2020-12-14 03:02

I\'m currently learning Python, and I have to work on a Python 2.7 project.

Accessing \"module scope\" variables in functions of the module itself is a bit confusing

4条回答
  •  旧时难觅i
    2020-12-14 03:22

    Importing a module within itself can have unwanted side effects (like evaluating statements more than once.) I would suggest using "Way 1" and a tool like pylint to help verify your code and enforce common practices.

    PyLint can be found at: http://www.logilab.org/project/pylint

提交回复
热议问题