OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Python Global variable of files

  • Thread starter Thread starter Little Sun
  • Start date Start date
L

Little Sun

Guest
I have question about global variable.

I have file A:

Code:
global var = 0

, file B.

Code:
import A
for i in range(1000):
    A.var += 1
    time.sleep(1)

and file C:

Code:
print(A.var)

Well, how can I get the variable (A.var of B) by C when B is running?

Ex. Resule C is 60 when B has been running 60s ago.

Thanks for reading!
<p>I have question about global variable.</p>
<p>I have file A:</p>
<pre><code>global var = 0
</code></pre>
<p>, file B.</p>
<pre><code>
import A
for i in range(1000):
A.var += 1
time.sleep(1)
</code></pre>
<p>and file C:</p>
<pre><code>
print(A.var)
</code></pre>
<p>Well, how can I get the variable (A.var of B) by C when B is running?</p>
<p>Ex. Resule C is 60 when B has been running 60s ago.</p>
<p>Thanks for reading!</p>
 

Online statistics

Members online
0
Guests online
3
Total visitors
3
Top