view python/example/monkeypatch.py @ 760:d0b975ffabdf

http://serverfault.com/questions/132055/how-to-check-if-emacs-is-in-gui-mode-and-execute-tool-bar-mode-only-then
author Jeff Hammel <k0scist@gmail.com>
date Tue, 15 Dec 2015 12:32:34 -0800
parents cd9d65e6e2ab
children
line wrap: on
line source

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import argparse
import sys

__all__ = ['main']

class ExampleClass(object):
    def __init__(self, to_patch):
        if to_patch:
            self.output = lambda x, y: 'Patched!'
    def output(self, x, y):
        return '[{}] "{}"'.format(x, y)


if __name__ == '__main__':
    obj = ExampleClass(False)
    print (obj.output(1, 2))
    newobj = ExampleClass(True)
    print (newobj.output(3, 4))