How can I override a constant in an imported Python module?

后端 未结 4 802
再見小時候
再見小時候 2020-12-17 10:33

In my application I am using module within the package example called examplemod.

My app:

from example imp         


        
4条回答
  •  渐次进展
    2020-12-17 10:57

    Yes, but it'll only work as expected with fully qualified access paths to modules:

    import example
    example.examplemod.config.CONSTANT = "Better value"
    example.examplemod.do_stuff()
    

提交回复
热议问题