PyMyth: Global variables are evil... WRONG!
jongiddy at gmail.com
Tue Nov 12 16:33:50 CET 2013
On Tuesday, November 12, 2013 3:05:25 PM UTC, Rick Johnson wrote:
> When i type "math.pi", i "feel" as though i'm accessing an
> interface, BUT I'M NOT!
I'm not sure where you get the feeling you're accessing an interface. If I typed this, I would feel like I was trying to change a fundamental constant.
You have just demonstrated that going into other modules and changing their attributes (whether they are variables, functions or classes) is generally a BAD idea, and I don't think I've ever seen anyone recommend doing this, except possibly as a workaround or for debugging purposes.
On the other hand, you initially suggested that modifying globals contained within namespaces (i.e. modules) is a good way to communicate between modules. That is, you suggested in your initial post that going into other modules and changing their attributes is a GOOD idea.
This inconsistency is why I was asking for a good example (i.e. a realistic example where the use of global variables provides the best solution).
Just because a tool allows you to do something does not make it a good idea. Try this paraphrase of your last post: Ladder designers act like standing on the top rung is SO evil, but then they give us ladders with a top rung, Are they just trying to fool themselves, or fool us?
More information about the Python-list