Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
use of global
#12
(Sep-30-2019, 10:33 AM)buran Wrote: Actually it's a perfect example as to why using global variables should be avoided... There are problems on so many levels.
[ ... ]
You are using star import - from testglobalsextimport import *. Like globals this is bad practice and strongly discouraged.

Wpo, I think Buran has been wisely advising for a very long time in here (more than 4000 posts!!!) and is a moderator here. Computer languages, like almost everything else, evolve and change with time. If you use books like myself, you can find that even in books printed in 2019, they dedicate just one paragraph to the f-string formatting, while in internet (including this site) the use of %-formatting is deprecated in favour of the advised f-string formatting. Dedicated programmers find bugs and advise in order to code better and with more efficiency.

So, I would follow Buran, when advising not to use global variables.

(Sep-30-2019, 11:56 AM)wpo Wrote: I've been experimenting further and I think that I got most of it working! See below. "most of it" because I conclude that passing values (in global variables) between functions that reside in different modules is (almost???) impossible. Between modules, values are always to be passed as arguments in function calls and in returns.

It seems that you concur with him.

All the best,

(Sep-30-2019, 12:47 PM)buran Wrote: with 4000+ lines of code base better put your efforts to refactor without using globals.

Oops! Once again, seconds away ... Sorry!

All the best,
newbieAuggie2019

"That's been one of my mantras - focus and simplicity. Simple can be harder than complex: You have to work hard to get your thinking clean to make it simple. But it's worth it in the end because once you get there, you can move mountains."
Steve Jobs
Reply


Messages In This Thread
use of global - by wpo - Sep-30-2019, 08:53 AM
RE: use of global - by buran - Sep-30-2019, 09:00 AM
RE: use of global - by wpo - Sep-30-2019, 09:13 AM
RE: use of global - by newbieAuggie2019 - Sep-30-2019, 10:28 AM
RE: use of global - by newbieAuggie2019 - Sep-30-2019, 10:34 AM
RE: use of global - by buran - Sep-30-2019, 10:33 AM
RE: use of global - by newbieAuggie2019 - Sep-30-2019, 12:48 PM
RE: use of global - by wpo - Sep-30-2019, 10:38 AM
RE: use of global - by newbieAuggie2019 - Sep-30-2019, 10:55 AM
RE: use of global - by buran - Sep-30-2019, 10:43 AM
RE: use of global - by wpo - Sep-30-2019, 11:56 AM
RE: use of global - by buran - Sep-30-2019, 12:47 PM
RE: use of global - by wpo - Sep-30-2019, 01:27 PM
RE: use of global - by newbieAuggie2019 - Sep-30-2019, 02:14 PM
RE: use of global - by ichabod801 - Sep-30-2019, 01:43 PM
RE: use of global - by wpo - Sep-30-2019, 03:06 PM
RE: use of global - by buran - Sep-30-2019, 03:21 PM
RE: use of global - by ichabod801 - Sep-30-2019, 03:30 PM
RE: use of global - by stullis - Sep-30-2019, 07:45 PM
RE: use of global - by micseydel - Oct-02-2019, 10:06 PM
RE: use of global - by steve_shambles - Oct-17-2019, 04:21 AM
RE: use of global - by buran - Oct-17-2019, 06:13 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Global variable does not seem to be global. Columbo 6 5,328 Jul-15-2019, 11:00 PM
Last Post: Columbo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020