79137750

Date: 2024-10-29 14:58:24
Score: 1
Natty:
Report link

I'm sorry I am adding this as an answer, but the system here does not allow me to comment untill I have gained 50 rep. So this probably should just be a comment to the accepted answer, but alas. I'll try to make it worth your while.

Importing a config can be made better by specifying what you are importing.

Instead of just import config, you can do from config import foo, bar, listofthings, which makes you actually know (better) what you are importing, and way less susceptible to unexpected behaviour from someone "hacking" the config file.

In addition, this also makes it so you don't have to reference your variables with dot-notation as blinky = config.foo['blinky'], but just blinky = foo['blinky']

In addition you can also import classes and functions, which is way harder with another method.

So I see some benefit to doing it this way.

Reasons:
  • Blacklisted phrase (1): to comment
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Danny Kip