Created
December 31, 2024 14:52
-
-
Save FFY00/c2a134d402eeffd7d556044c63334ba2 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 HelloDescriptor: | |
def __get__(self, obj, objtype=None): | |
return self.hello | |
class Foo(HelloDescriptor): | |
def hello(self): | |
return 42 | |
class Bar(HelloDescriptor): | |
hello = Foo() | |
class Baz(HelloDescriptor): | |
hello = Bar() | |
class Spam(HelloDescriptor): | |
hello = Baz() | |
spam_instance = Spam() | |
print(spam_instance.hello()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment