With the ease of argument passing to and from functions in Python, why would anyone want to use global variables. Isn't that an open invitation for mistakes to happen? Yet, I see code in threads here that abound with globals. I am a little confused here.
sneekula
969
Nearly a Posting Maven
Recommended Answers
Jump to PostYes, I would say avoid globals like a pest! They are used by folks familiar with C/C++ programming, where passing arguments, particularly multiple arguments are a possible pointer nightmare.
Here is an example where a global might be useful ...
x = 0 def incr_x() : …
All 3 Replies
vegaseat
1,735
DaniWeb's Hypocrite
Team Colleague
bumsfeld
413
Nearly a Posting Virtuoso
jrcagle
77
Practically a Master Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.