Python: Problem with local modules shadowing global modules

后端 未结 2 457
無奈伤痛
無奈伤痛 2020-12-30 05:41

I\'ve got a package set up like so:

packagename/
    __init__.py
    numbers.py
    tools.py
    ...other stuff

Now inside tools.py

2条回答
  •  孤城傲影
    2020-12-30 06:01

    I try to avoid shadowing the standard library. How about renaming your module to "_numbers.py" ?

    And of course, you could still do:

    import _numbers as numbers
    

提交回复
热议问题