Skip to content

Instantly share code, notes, and snippets.

@maxfischer2781
Created January 11, 2022 09:25
Show Gist options
  • Save maxfischer2781/3041fa1e8a27e7e74a14aacc5efa37c0 to your computer and use it in GitHub Desktop.
Save maxfischer2781/3041fa1e8a27e7e74a14aacc5efa37c0 to your computer and use it in GitHub Desktop.
Draft for special method lookup
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