prgbenz
prgbenz

Reputation: 1189

How do I make the parameters parsed by configparser visible to every .py

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!

Upvotes: 0

Views: 85

Answers (1)

Nico
Nico

Reputation: 1328

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.

Upvotes: 2

Related Questions