Open sgerodes opened 3 years ago
I've had the same problems as well. I was messing around with dunders, and some raise KeyError
where the attr definitely exists (I checked with __dict__
and similar things). However, this is peculiar:
It didn't raise an error. Do only some dunders not work?
Also, other issues with the same format (cursing __something__
fails) seem to be the same problem, but just more specific (cursing __init__
fails, __iter__
fails, etc)
__str__
and __new__
have been registered
and my pull request will register a lot more You know what? Ill try to register them all.
Another proof that cursing dunder methods fails.
I was trying to make numeric types callable, to implement implicit multiplication as it's known in some programming languages such as Julia.
from forbiddenfruit import curse, reverse
def __call__(self, other, /):
return self * other
for cls in (int, float, complex):
curse(cls, "__call__", __call__)
print(2(6))
This of course gave a SyntaxWarning that int
objects are not callable, but also threw a KeyError: '__call__'
.
fails with: ...
Also other dunder methods fails. e.g.: