Closed bscully27 closed 2 months ago
Hi it sounds like what you are looking for is a method on the dict class instances and not a class method.
Try:
from forbiddenfruit import curse
def attempt(self):
return list(self.keys())
curse(dict, "my_keys", attempt)
d = dict(test=1)
d.my_keys()
Perfect! Thank you.
This repo is very cool
Is it possible to add a class method to python 3.8+ dictionaries?
Goal: dict.keys() or dict.my_added_method() to return list(dict.keys()) for indexing.
My failed attempt: