"Avoid THIS Bad Practise In Python": An Introduction to .env Files

  Рет қаралды 22,604

Indently

Indently

Жыл бұрын

Hardcoding your keys / sensitive information in your scripts is a strong red flag when it comes to coding. Let me show you a better alternative by using .env files to store your sensitive information!
▶ Become job-ready with Python:
www.indently.io
▶ Follow me on Instagram:
/ indentlyreels

Пікірлер: 51
@pietraderdetective8953
@pietraderdetective8953 6 ай бұрын
i really love your Python syntax which includes types both for the variables and the function return. not a lot of python youtube channels properly uses types like that. I'm currently learning C and Rust, and I have learned Cython before so these static typing are very important.
@Indently
@Indently 5 ай бұрын
Always happy to see an appreciator of type annotations in Python :) I programmed in Python without them for a while, and that freedom showed me why they were so important in the end. So my older tutorials might not have them always, but all my future tutorials will definitely always have them!
@fasanojp
@fasanojp 3 ай бұрын
An alternative is to use the Python keyring package. An advantage is that the sensitive information is not stored in plain text on the local machine.
@SonuSingh-sn8qg
@SonuSingh-sn8qg Жыл бұрын
Awesome! Going to implement this tomorrow
@dk-ww3kp
@dk-ww3kp Жыл бұрын
You helped me so much with this video thank you keep up the awesome content👏🔥
@ozzman530
@ozzman530 Жыл бұрын
I think this is doing the same thing when I store variables in my Linux environment. per the .profile, or .bashrc. Is that accurate? I use this method to store detail but you have to keep an eye on file permissions. On top of that I have went so far and finding ways to encrypt the info using a seed file, but again finding suitable file permissions and places to store the seed should be concerns.
@JoePolasek
@JoePolasek 5 ай бұрын
Awesome! Now I finally understand what .env files are for :D
@lucazirkelbach3151
@lucazirkelbach3151 Жыл бұрын
Whats your code editor you use
@alexjando4880
@alexjando4880 Жыл бұрын
Great video, but if you want to do something native to python, you could do it by using either simple json file, or by just iterating each line of the .env file and adding the environment variables yourself.
@EricHuang-cc2uu
@EricHuang-cc2uu 2 ай бұрын
Great video🎉, compare to normal json file or txt file, is there any advantage using .env file?
@MannyBernabe
@MannyBernabe 10 ай бұрын
helpful. thank you.
@gravity9999
@gravity9999 Жыл бұрын
What text editor/IDE you are using
@yurix650
@yurix650 Жыл бұрын
Thanx!
@ali-g
@ali-g Жыл бұрын
Awesome video! What is the difference between a config file and a .env file?
@antonisstellas741
@antonisstellas741 11 ай бұрын
You can actually do the same job with a config file. However, generally in a config file you save non-sensitive information.
@pfaelzer2234
@pfaelzer2234 Жыл бұрын
Good video, but in my case very strange. I took over the source code from you and also .env. But if I execute print('USERNAME...) I see my original USERNAME and not the USERNAME written in .env. Do you know why?
@TheRealLAC
@TheRealLAC Жыл бұрын
In this instance, if you wish to print to console, you need a formatted string, as you are treating the print statement as plain text. print(f"My username is {USERNAME}!") This assumes you have imported USERNAME from the .env and already instanced and defined it in the script you are currently working in.
@pfaelzer2234
@pfaelzer2234 Жыл бұрын
@@TheRealLAC under Ubuntu the variable USERNAME is reserved. If I take username it works.
@arnabmondal2680
@arnabmondal2680 10 ай бұрын
Make a a video how to atore environment variables/secret variables in github and retrieve in it the code , because if i hist the github repo on a platform like c panel , i want make sure api keys correctly retrieved
@dipeshsamrawat7957
@dipeshsamrawat7957 Жыл бұрын
Excellent❤
@MyManJohnny
@MyManJohnny Жыл бұрын
Another option would be to create a json file, and then write a simple wrapper class that you can use to load and access the data.
@kaiserkonok
@kaiserkonok Жыл бұрын
Which IDE or text editor you are using? Please reply
@Indently
@Indently Жыл бұрын
PyCharm
@krzysiekkrzysiek9059
@krzysiekkrzysiek9059 Жыл бұрын
Great video.
@rish9422
@rish9422 5 ай бұрын
tysm!!
@AliHamza-en8cn
@AliHamza-en8cn Жыл бұрын
Great video. But anybody can have access env in local. Any alternative to be more secure and how the use in production.
@Indently
@Indently Жыл бұрын
I don't understand what what you mean. The only person who has access to your env on local is you and whoever else uses your computer.
@AliHamza-en8cn
@AliHamza-en8cn Жыл бұрын
@@Indently I mean, for example, you have a project already in an exe that is passed to the end user and the script has to connect to the database if we save it in env, the people who access that computer will be able to see it and that env is not encrypted, right?
@Moonz97
@Moonz97 Жыл бұрын
​@@AliHamza-en8cn build a server in between those layers as a relay. So your end user connects to your server, and your server connects to the DB. More secure that way since you can control what goes in your DB and users cant access the DB directly.
@AliHamza-en8cn
@AliHamza-en8cn Жыл бұрын
@@Moonz97 Thanks bro for information. Any suggestions of server?
@lucaluisi8860
@lucaluisi8860 Жыл бұрын
Which Is your theme?
@doonk6004
@doonk6004 2 ай бұрын
I keep a .env.example file in my repos whenever I need to communicate to users and other devs which environment keys need to be set up.
@Sinke_100
@Sinke_100 Жыл бұрын
Providing types for every variable is maybe more professional aproach, but it's so iritating, I never do it
@ricgondo
@ricgondo Жыл бұрын
Thanks!
@Indently
@Indently Жыл бұрын
Thank you for your genorosity! :)
@ricgondo
@ricgondo Жыл бұрын
No no sir!!! This was cool!!!
@appuz9220
@appuz9220 Жыл бұрын
Which IDE is this?
@yurix650
@yurix650 Жыл бұрын
pycharm's new theme
@appuz9220
@appuz9220 Жыл бұрын
​@@yurix650is there a name for the new theme i can't find it
@DDecorah
@DDecorah Жыл бұрын
@aafan.kuware
@aafan.kuware Жыл бұрын
I use python-decouple.
@mortysmith666
@mortysmith666 8 ай бұрын
Just like Env reader in dart
@jjt229
@jjt229 Жыл бұрын
What about bad english ?
@DDecorah
@DDecorah Жыл бұрын
in@it host-ip
@Assxz
@Assxz Жыл бұрын
sei italiano?
@Oler-yx7xj
@Oler-yx7xj Жыл бұрын
I thought, your channel was called Identity...
Should You Even Bother With LEARNING PYTHON In 2023?
5:01
Indently
Рет қаралды 13 М.
5 Good Python Habits
17:35
Indently
Рет қаралды 414 М.
The day of the sea 🌊 🤣❤️ #demariki
00:22
Demariki
Рет қаралды 106 МЛН
Did you believe it was real? #tiktok
00:25
Анастасия Тарасова
Рет қаралды 49 МЛН
OMG🤪 #tiktok #shorts #potapova_blog
00:50
Potapova_blog
Рет қаралды 18 МЛН
Became invisible for one day!  #funny #wednesday #memes
00:25
Watch Me
Рет қаралды 52 МЛН
Store & manage secrets like API keys in Python - Tech Tip Tuesdays
12:46
10 Nooby Mistakes Devs Often Make In Python
24:31
Indently
Рет қаралды 50 М.
Why You Shouldn't Nest Your Code
8:30
CodeAesthetic
Рет қаралды 2,6 МЛН
The most important Python script I ever wrote
19:58
John Watson Rooney
Рет қаралды 159 М.
AVOID Making "THIS Stupid Mistake" In Python (It's bad)
6:14
5 Really Cool Python Functions
19:58
Indently
Рет қаралды 55 М.
5 Awful Python Mistakes To Avoid
22:13
Indently
Рет қаралды 23 М.
The day of the sea 🌊 🤣❤️ #demariki
00:22
Demariki
Рет қаралды 106 МЛН