Editing Configuration Files For Python
Jump to navigation
Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 19: | Line 19: | ||
I have decided for my use that configuring everything in a single python, .py, file is the best solution for me ( and I think for many of you ) I will describe how I do it and then will give some of the reasons why I think the method is so very useful. | I have decided for my use that configuring everything in a single python, .py, file is the best solution for me ( and I think for many of you ) I will describe how I do it and then will give some of the reasons why I think the method is so very useful. | ||
− | == How | + | == How The Basics == |
No matter what the application I put the configuration in a file called parameters.py and use it to define/create a class called Parameters. It is full of instance variables like self.logging_id = "MyLoggingId". Any part of my system that wants to know a parameter value takes the instance of Parameters created at startup and accesses its instance value this: '''logging_id = system_parameter.logging_id'''. It is very easy. | No matter what the application I put the configuration in a file called parameters.py and use it to define/create a class called Parameters. It is full of instance variables like self.logging_id = "MyLoggingId". Any part of my system that wants to know a parameter value takes the instance of Parameters created at startup and accesses its instance value this: '''logging_id = system_parameter.logging_id'''. It is very easy. |