0

I'm very new to python. My question is about pythonic convention for doing these kind of things. I have some constants which I places in some separate module. It looks like:

CONST = 'value'
ANOTHER_CONST = 'value2'

But there are some SECURE_TOKEN which is located on some file on a specific host. I know only the path to the file, but that's it. What is the pythonic way to provide access to the SECURE_TOKEN? Is it common to put some function so it all look like this:

CONST = 'value'
ANOTHER_CONST = 'value2'
def get_secure_token():
     #return the token from the file

Or maybe I should not mix module for static constants and functions.

St.Antario
  • 26,175
  • 41
  • 130
  • 318
  • Whether you mix constants and functions in a single module or not is up to you, as this is a not a settled discussion. I would only advise you to keep the scope of the constants and functions minimal. Notice that you could write a small working example and get reviews for it in Code Review SE, which is more appropriate for this type of question. – Bernardo Sulzbach Nov 15 '17 at 12:50
  • You should look at [this](https://stackoverflow.com/questions/1596963/read-a-file-from-server-with-ssh-using-python) – Abhijeetk431 Nov 15 '17 at 14:26

0 Answers0