What's the Pythonic way of supporting constants across modules in one project as well as across projects?

Viewed 22

I'm using pycharm if that matters. In one project, I have several python files and I'd like to use a set of constants across all of them. What is the pythonic way of doing that since my attempt fails for a reason unknown to me?

constants.py

WIDTH = 3

main.py

import constants

print(WIDTH)

This fails for unresolved reference WIDTH

Also, I have another project that I'd like to use the same constants in it. How is that typically handled since files are in different directories? I want to believe that there's a way to not duplicate the constants.py file.

0 Answers
Related