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

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

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
@dk-ww3kp
@dk-ww3kp Жыл бұрын
You helped me so much with this video thank you keep up the awesome content👏🔥
@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 6 ай бұрын
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!
@SonuSingh-sn8qg
@SonuSingh-sn8qg Жыл бұрын
Awesome! Going to implement this tomorrow
@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.
@EricHuang-cc2uu
@EricHuang-cc2uu 2 ай бұрын
Great video🎉, compare to normal json file or txt file, is there any advantage using .env file?
@lucazirkelbach3151
@lucazirkelbach3151 Жыл бұрын
Whats your code editor you use
@gravity9999
@gravity9999 Жыл бұрын
What text editor/IDE you are using
@arnabmondal2680
@arnabmondal2680 11 ай бұрын
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
@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.
@JoePolasek
@JoePolasek 6 ай бұрын
Awesome! Now I finally understand what .env files are for :D
@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.
@MannyBernabe
@MannyBernabe 11 ай бұрын
helpful. thank you.
@kaiserkonok
@kaiserkonok Жыл бұрын
Which IDE or text editor you are using? Please reply
@Indently
@Indently Жыл бұрын
PyCharm
@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.
@dipeshsamrawat7957
@dipeshsamrawat7957 Жыл бұрын
Excellent❤
@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?
@krzysiekkrzysiek9059
@krzysiekkrzysiek9059 Жыл бұрын
Great video.
@yurix650
@yurix650 Жыл бұрын
Thanx!
@lucaluisi8860
@lucaluisi8860 Жыл бұрын
Which Is your theme?
@rish9422
@rish9422 5 ай бұрын
tysm!!
@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.
@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
@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.
@ricgondo
@ricgondo Жыл бұрын
Thanks!
@Indently
@Indently Жыл бұрын
Thank you for your genorosity! :)
@ricgondo
@ricgondo Жыл бұрын
No no sir!!! This was cool!!!
@Sinke_100
@Sinke_100 Жыл бұрын
Providing types for every variable is maybe more professional aproach, but it's so iritating, I never do it
@DDecorah
@DDecorah Жыл бұрын
@mortysmith666
@mortysmith666 9 ай бұрын
Just like Env reader in dart
@aafan.kuware
@aafan.kuware Жыл бұрын
I use python-decouple.
@DDecorah
@DDecorah Жыл бұрын
in@it host-ip
@jjt229
@jjt229 Жыл бұрын
What about bad english ?
@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
Рет қаралды 445 М.
🤔Какой Орган самый длинный ? #shorts
00:42
Heartwarming Unity at School Event #shorts
00:19
Fabiosa Stories
Рет қаралды 18 МЛН
25 nooby Python habits you need to ditch
9:12
mCoding
Рет қаралды 1,7 МЛН
Why You Shouldn't Nest Your Code
8:30
CodeAesthetic
Рет қаралды 2,6 МЛН
Python dataclasses will save you HOURS, also featuring attrs
8:50
The Complete Guide to Python Virtual Environments!
15:52
teclado
Рет қаралды 335 М.
What Are APIs? - Simply Explained
6:49
Simply Explained
Рет қаралды 874 М.
Store & manage secrets like API keys in Python - Tech Tip Tuesdays
12:46
Automate your job with Python
6:07
John Watson Rooney
Рет қаралды 383 М.
Python 101: Learn the 5 Must-Know Concepts
20:00
Tech With Tim
Рет қаралды 1,1 МЛН