![]() ![]() ![]() Project_name=config_file.get("project_name") Creating more complex Python config files Then in order to use these variables in our Python file, run.py, we will do the following: import yamlĬonfig_file = yaml.safe_load(open("config.yaml", "rb")) Here I will demonstrate a simple of example of how this can be done.įirst we will create our YAML file, config.yaml, to hold the variables: project_name: "My Project" One of the easiest, and most common, ways to create a config file is to create a YAML file which stores the values and then read this into the Python file. How do I create a config file for my data science project in Python? Storing your variables in a single config file improves your quality of life by reducing the time to make changes and also improves your code quality in two key ways: it makes your code more readable for others, and it reduces the chance of bugs occuring in your code due to mistyped variable names. Should I use YAML config files for my data science project? ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |