stupid-python-tricks
stupid-python-tricks copied to clipboard
improvements for gradually_worse_pi
Hello, Mark. We have a small conversation on PyCon DE 2022 after your talk. I have a small improvements for your "gradually_worse_pi"
class my_prop(math.__class__):
_pi = math.pi`
@property
def pi(self):
self._pi += 0.0001
return self._pi
math.__class__ = my_prop
Here we have an inheritance from math module class, that's why we don't need override getattr and also we don't need change the sys import list. Probably those code can be more elegant and Pythonic.