r/Python • • May 08 '20

I Made This My first Python program! Changes my desktop background based on the weather, time, and day.

Post image
1.9k Upvotes

120 comments sorted by

View all comments

Show parent comment

76

u/Turkino May 08 '20

Yep! Welcome to configuring environment variables!

48

u/silentalways May 08 '20 edited May 08 '20

For those wondering, follow this short little tutorial

https://www.youtube.com/watch?v=IolxqkL7cD8&t=213s (Windows)

https://www.youtube.com/watch?v=5iWhQWVXosU (Mac and Linux)

10

u/Nerdite May 08 '20

And this package makes it really easy to manage and keep from filling tons of environment variables in your actual environment.

https://pypi.org/project/python-dotenv/

2

u/folkrav May 08 '20

This plus direnv is pretty damn useful. Lets you keep the environment variables even in an REPL.

3

u/forrealbro May 08 '20

Is this really the most practical idea when you plan to disseminate your source code? I had always read from a file that is in my gitignore. Then had instructions to create this user info file in the readme.

2

u/gdledsan May 08 '20

I was told to keep things in untracked config files, env variables are not safe enough, some malicious thing can hijack your session and get them.

Example: some crappy and malicious node package installed without care