Python Forum
Help with variable in between modules
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with variable in between modules
#2
You are using global wrong. You do not need to use "global loop_valve" in the for loop. The for loop is running in the global context, and any variables created in the for loop are global. You don't declare any variables in Validate() as global, so all the variables are local. w_loop in Validate is not the same variable as w_loop outside Validate().

loop_value has a different problem. loop_value inside Validate() is a local variable. Any changes to loop_valve inside Validate have no effect on loop_valve outoside Validate(). Validate() returns a value, but you don't use the return value anywhere.

And there is another problem that this code:
loop_valve =+1
Is the same as
loop_valve = 1
Did you mean this:
loop_valve += 1
Which is the same as:
loop_valve = loop_valve + 1
Why does Validator open a file every time? Does input.txt change? If input.txt changes, why does it change? Are you using a file to communicate between the generator and the validator? Why? Are they different processes?
llxxzz likes this post
Reply


Messages In This Thread
Help with variable in between modules - by llxxzz - Jul-31-2023, 02:27 PM
RE: Help with variable in between modules - by deanhystad - Jul-31-2023, 03:17 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  change value of a global variable across all modules aster 5 5,218 Jan-01-2019, 06:42 PM
Last Post: aster
  Modules issue, pip3 download modules only to pyhton3.5.2 not the latest 3.6.1 bmohanraj91 6 8,575 May-25-2017, 08:15 AM
Last Post: wavic

Forum Jump:

User Panel Messages

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