Created
January 11, 2022 09:25
-
-
Save maxfischer2781/3041fa1e8a27e7e74a14aacc5efa37c0 to your computer and use it in GitHub Desktop.
Draft for special method lookup
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
def slot_get(ob: object, field: str): | |
tp = type(ob) | |
try: | |
field = tp.__dict__[field] | |
except KeyError: | |
return getattr(super(tp, ob), field) | |
else: | |
try: | |
descriptor_get = field.__get__ | |
except AttributeError: | |
return field | |
else: | |
return descriptor_get(ob, tp) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment