Created
July 3, 2019 18:20
-
-
Save claudijd/9dfe804e99c0f090136a86f9ac764ac7 to your computer and use it in GitHub Desktop.
demoing global override and comms
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
thing = "foo" | |
class Baz(): | |
def override_thing(self): | |
global thing | |
thing = 1 | |
def update_thing(self): | |
global thing | |
thing += 1 | |
def read_thing(self): | |
global thing | |
return thing | |
baz = Baz() | |
baz2 = Baz() | |
print thing | |
baz.override_thing() | |
print thing | |
baz.update_thing() | |
print thing | |
print baz.read_thing() | |
print baz2.read_thing() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$ python ~/Desktop/shark.py
foo
1
2
2
2