Using global variables between files?

前端 未结 7 1687
轻奢々
轻奢々 2020-11-22 03:43

I\'m bit confused about how the global variables work. I have a large project, with around 50 files, and I need to define global variables for all those files.

What

7条回答
  •  野的像风
    2020-11-22 04:12

    Using from your_file import * should fix your problems. It defines everything so that it is globally available (with the exception of local variables in the imports of course).

    for example:

    ##test.py:
    
    from pytest import *
    
    print hello_world
    

    and:

    ##pytest.py
    
    hello_world="hello world!"
    

提交回复
热议问题