Mercurial > hg > config
annotate python/example/monkeypatch.py @ 803:70e9f82c2443
* prime actually doesnt work; if i had a decent CI for my own software, i would have known that; but i dont
* resource_filename.py even _says_ example in it. let us hope it is telling the truth
| author | Jeff Hammel <k0scist@gmail.com> |
|---|---|
| date | Fri, 28 Oct 2016 17:00:37 -0700 |
| parents | cd9d65e6e2ab |
| children |
| rev | line source |
|---|---|
| 718 | 1 #!/usr/bin/env python |
| 2 # -*- coding: utf-8 -*- | |
| 3 | |
| 4 import argparse | |
| 5 import sys | |
| 6 | |
| 7 __all__ = ['main'] | |
| 8 | |
| 9 class ExampleClass(object): | |
| 10 def __init__(self, to_patch): | |
| 11 if to_patch: | |
| 12 self.output = lambda x, y: 'Patched!' | |
| 13 def output(self, x, y): | |
| 14 return '[{}] "{}"'.format(x, y) | |
| 15 | |
| 16 | |
| 17 if __name__ == '__main__': | |
| 18 obj = ExampleClass(False) | |
| 19 print (obj.output(1, 2)) | |
| 20 newobj = ExampleClass(True) | |
| 21 print (newobj.output(3, 4)) |
