Skip to content

Instantly share code, notes, and snippets.

@vivkin
Created March 11, 2017 18:05
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 vivkin/6c176e9bf6a4626865ccf2d4b6eeb1b3 to your computer and use it in GitHub Desktop.
Save vivkin/6c176e9bf6a4626865ccf2d4b6eeb1b3 to your computer and use it in GitHub Desktop.
google/python-fire in 30 seconds
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