Created
October 4, 2021 08:20
-
-
Save FerdinaKusumah/f05d2cbfbd50201800139a2b48e9b8fc to your computer and use it in GitHub Desktop.
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
class FooBar: | |
class_attr: str = "foo bar" | |
def __init__(self, instance_attr: str): | |
self.instance_attr = instance_attr | |
if __name__ == "__main__": | |
foo = FooBar("foo") | |
bar = FooBar("bar") | |
# get value from init fooBar class | |
print(foo.class_attr) | |
FooBar.class_attr = "foo !!" | |
# print current class attr value, it will print "foo !!" | |
print(foo.class_attr) | |
# check bar class attr value, this will print "foo !!" too | |
# this is weird ?? | |
print(bar.class_attr) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment