Python Forum
change value of a global variable across all modules
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
change value of a global variable across all modules
#2
If you run one.py it is not run as module one but as module __main__. The import one in module two imports a new copy of the execution of one.py. That's why your code doesn't work.
Reply


Messages In This Thread
RE: change value of a global variable across all modules - by Gribouillis - Dec-31-2018, 01:12 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Help with writing monitored data to mysql upon change of one particular variable donottrackmymetadata 3 381 Apr-18-2024, 09:55 PM
Last Post: deanhystad
  It's saying my global variable is a local variable Radical 5 1,255 Oct-02-2023, 12:57 AM
Last Post: deanhystad
  Help with variable in between modules llxxzz 5 883 Jul-31-2023, 04:20 PM
Last Post: Gribouillis
  how can a variable change if I haven't changed it? niminim 5 3,160 Apr-07-2021, 06:57 PM
Last Post: niminim
  Variable scope - "global x" didn't work... ptrivino 5 3,118 Dec-28-2020, 04:52 PM
Last Post: ptrivino
  Change variable value during a while loop? penahuse 2 4,150 Nov-15-2020, 11:53 PM
Last Post: penahuse
  Change variable in an outside file ebolisa 5 2,728 Nov-11-2020, 04:41 AM
Last Post: ebolisa
  Spyder Quirk? global variable does not increment when function called in console rrace001 1 2,271 Sep-18-2020, 02:50 PM
Last Post: deanhystad
  Change name of variable samuelbachorik 2 2,121 Aug-10-2020, 02:34 PM
Last Post: deanhystad
  NameError for global variable leviporton 3 2,597 Jul-10-2020, 06:51 PM
Last Post: bowlofred

Forum Jump:

User Panel Messages

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