I like to parse parameters, vars by using configparser. However, I have to
pass the instance to every .py, in order to get the parameters.
What is the most elegant way to make the parameters visible to every .py ?
Thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You could have “config” module, which parses the options into a global variable (in that same module) which you then include in all places where you need it.
Admittedly though, I do agree with delnan’s comment, avoid globals if it’s possible as in general it will push you to design better code. Personally I don’t find them evil, as delnan says there are some cases where they still make sense.