Where to store secret keys and password in Python

I have a small Python program that uses the secret key of the Google Maps API. I am ready to register my code, and I do not want to include the secret key in SVN.

In a canonical PHP application, you set up secret keys, database passwords, and other application-specific configurations in LocalSettings.php. Is there a similar file / location that Python programmers expect to find and modify?

+3
source share
3 answers

No, there is no standard location - on Windows it is usually in the directory os.path.join(os.environ['APPDATA'], 'appname'), but on Unix it is usually os.path.join(os.environ['HOME'], '.appname').

+3
source

. .

.

+3

Any path can reference the user's home directory in a cross-platform manner, extending the common ~ (tilde) with os.path.expanduser(), for example:

appdir = os.path.join(os.path.expanduser('~'), '.myapp')
+1
source

Source: https://habr.com/ru/post/1712368/


All Articles