Created
March 11, 2017 18:05
-
-
Save vivkin/6c176e9bf6a4626865ccf2d4b6eeb1b3 to your computer and use it in GitHub Desktop.
google/python-fire in 30 seconds
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function | |
import sys | |
class Calculator(object): | |
"""A simple calculator class.""" | |
def double(self, number): | |
return 2 * number | |
if __name__ == '__main__': | |
#fire.Fire(Calculator) | |
code = 'print(Calculator().' + sys.argv[1] + '(' + ','.join(sys.argv[2:]) + '))' | |
print(code) | |
eval(code) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment