Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.27 KB | None | 0 0
  1. # File with my_func and global
  2. global_var = 0
  3. def my_func():
  4.     global global_var
  5.     global_var +=1
  6.  
  7. # File with my_func no global
  8. def my_func():
  9.     my_func.global_var +=1
  10.  
  11. my_func.global_var = 0
  12.  
  13. def other_func():
  14.     #Can access the global
  15.     print(my_func.global_var)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement