https://github.com/google/python-fire
import fire
class Calculator(object):
“”"A simple calculator class.“”"
def double(self, number):
return 2 * number
def hello(self, name):
return “hello ” + name + “!”
if __name__ == ‘__main__‘:
fire.Fire(Calculator)
$ python calculator.py double --number=15
30
$ python calculator.py double 10
20
$ python test.py hello --name=“sam”
hello sam!
'python' 카테고리의 다른 글
[python] http url 끝에 //////를 지우기 (0) | 2019.09.27 |
---|---|
[python3] list/set/dict comprehension 예시 (0) | 2019.08.20 |
[flask] request의 get_json(force=True) 추가 (0) | 2019.01.24 |
[python] subprocess- paramiko 예시 (부제 - TypeError: startswith first arg must be bytes or a tuple of bytes, not str 해결하기) (0) | 2018.12.28 |
[python] pre-commit 추가하기 (0) | 2018.11.09 |