with many lessons on the internet you're going to notice that a lot of teachers are going to hard code their variables inside their scripts to show you how to use something such as an API key or a password they will do something such as password and say it is hello123 and they will include this in the script of course it's just for demonstration purposes you do not want to include any sensitive information in your scripts so today I'm going to be showing you how we can create an environment for these variables so that we can hide that sensitive information from people who should not see it so the very first thing I want to do is actually install a package and we're going to type in PIP install python dash dot environment so dot EnV and this is going to allow us to load that environment into our script so that we can use these hidden variables so I'm going to also increase the size of this script to 32 and the first thing we're going to do is import from dot environment we are going to import the load environment load dot environment and we're going to import OS so that we can grab the variables from the environment and that's just to get the Imports out of the way because we still haven't created the environment that we're going to use now to create an environment you just need to create a new file and you need to call it dot environment you can add a name in front of that if you want you might have different versions of these environments but if you don't have many versions just call it dot environment it's an easy name to remember and you'll see this in a lot of projects so now we have this dot environment file and in here we can add our sensitive information so if you have an API key just type in API key add the equal sign and you do not need to add quotation marks to make the API key work you just need to add the API key itself so it can be abc123 LOL and that can be your API key for example then maybe you want to test something with a username so here you can type in Luigi 123 that's my favorite username and a password so as you can see we're creating some sensitive information that should not be seen publicly it's only going to be stored locally so for the password we can type in Mario bro123 and that will be the sensitive information in our environment and you can add other things if you want but this is where we will keep our sensitive information so next we can go to main.pi and look at how we can retrieve that information inside our script so here we need to type in load dot environment to actually load this into the script so here we can type in load and we want to load dot environment now let's pretend we want to access the username and the password to do so we're going to create a username of type string and we're going to type in os.getenvironment and we want to get the username and if you're using a code editor such as pycharm it's going to show you the variables we have available plus their value so then we're going to type in username and for the password and I'm going to close the sidebar so for the password we're just going to type in password and you can see that the password will pop up and now we will have the opportunity to grab that environment variable so now we can print the username and the password or we can do whatever we want with it I'm printing it just to show you that we can grab those variables and as soon as we run that we're going to get luigi123 back and Mario Bro one two three so we've effectively grabbed that sensitive information using an environment and it's very important to note that you do need to include this in your dot git ignore because if you upload or you share this environment file with your GitHub project everyone's going to be able to see this ideally you want to store this locally you don't want other people to see it but you want to be able to use it so that your project can run properly so another place you could use this is if you have an API call that requires an API key you can easily grab that from the environment by saying API key of type string is equal to os.getenvironment and here we're going to get the API key now we can just pass that into the API call if we want so we can say the result of type string is going to equal the API call and the not the API key but the API call and the URL is going to be www.hellowworld.com with the key being specified as the API key and then we can print that result so once again we're retrieving that API key from the environment and when we run this it's going to give us a URL with the API key attached to the URL now that function doesn't really do anything it's of course just for demonstration purposes you don't want to expose your API key in any way in general so again I'm only using this for demonstration so that was the basic usage of the environment now another benefit of using an environment is that at any point in your project if you want to change one of these hard-coded sensitive variables you can just go to your project folder and you can go inside the environment and you can change the API key to something such as indently videos and it's going to update it throughout the project without actually having to edit anything in the project so anywhere that you decide to use this load.env will automatically grab the latest information from that environment so when you run the project now you'll get helloworld.com indently videos so again having this dot EnV file really helps with making sure that users that should not see this information don't see this information but I do also have to mention that there is a major con to this approach and that is that if you're working with other programmers on the same project you are going to have to manually communicate with them any changes you make in the dot EnV file because of course you're not going to be pushing this to your GitHub repository unless your project is private of course but otherwise you are going to have to find a way to communicate these keys with your colleagues in a much more secure way because again if you update this and it's not in the GitHub repository or anywhere public it's going to be hard for other people working on the project to understand that you did update this so that can take an extra layer of communication between you and your colleagues but otherwise that actually covers the basic usage of the dot EnV file and again it's a great is to store your sensitive information when you're working on your projects but definitely remember to include it in your dot git ignore if you don't want other people to see this information if you want to let other users know that they should have something similar to this you can always create a template you can say templates for example dot EnV and inside here you can copy this and you can leave these empty and you can push this to your GitHub repository so people understand that they do need to fill this out without actually being able to see your personal information but anyways guys that's actually all I wanted to cover in today's video so as always thanks for watching and I'll see you in the next video