Skip to content

Instantly share code, notes, and snippets.

@fruch
Created August 24, 2022 18:07
Show Gist options
  • Save fruch/79caa8ec2d8c54e4686cb27639644948 to your computer and use it in GitHub Desktop.
Save fruch/79caa8ec2d8c54e4686cb27639644948 to your computer and use it in GitHub Desktop.
class Foo:
x = None
def __init__(self):
self.x = set()
setattr(self, 'x', set())
@classmethod
def x(cls):
print(Foo.x)
return True
def what(self):
print(Foo.x)
print(Foo.x)
a = Foo()
print(a.x)
print(Foo.x)
a.what()
'''
<bound method Foo.x of <class '__main__.Foo'>>
set()
<bound method Foo.x of <class '__main__.Foo'>>
<bound method Foo.x of <class '__main__.Foo'>>
'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment