Python Forum
Best way(s) to organize and use "global" values?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Best way(s) to organize and use "global" values?
#3
That is a valid concern, but there are legitimate uses for globals, particularly "named constants".

It isn't reasonable to pass dozens of "global" and/or static variables to functions, so even if one decides to encapsulate them, how would you suggest that organization be accomplished? A global variable class with one instance passed around everywhere? The disadvantage of that solution is that one must then qualify every usage of the variable with the instance name, or use with statements everywhere they are used. And in order not to have to pass that instance in every function call the one instance name would need to be truly global in order for that to work. That seems clumsy to me, but I am only a novice at this language.

Your further advice and/or comments would be appreciated.

Peter
Reply


Messages In This Thread
RE: Best way(s) to organize and use "global" values? - by pjfarley3 - Sep-02-2020, 02:19 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How do I organize my simple ftp modules? blobdx7 3 636 Jan-05-2024, 01:23 PM
Last Post: Gribouillis
  How can I organize my code according to output that I want ilknurg 1 1,227 Mar-11-2022, 09:24 AM
Last Post: perfringo
Star Split and organize my Pandas Dataframe brunolelli 4 2,828 Apr-18-2021, 03:00 AM
Last Post: brunolelli
  Counting number of words and organize for the bigger frequencies to the small ones. valeriorsneto 1 1,746 Feb-05-2021, 03:49 PM
Last Post: perfringo
  Global variable does not seem to be global. Columbo 6 3,832 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