Created
March 8, 2017 04:51
-
-
Save attakei/31d85b146789fd92321bcf44fdff8207 to your computer and use it in GitHub Desktop.
This file contains 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
import fire | |
class Calcurator(object): | |
def add(self, first, second): | |
return int(first) + int(second) | |
if __name__ == '__main__': | |
fire.Fire(Calcurator) |
This file contains 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
import argparse | |
parser = argparse.ArgumentParser() | |
parser.add_argument('mode') | |
parser.add_argument('first') | |
parser.add_argument('second') | |
class Calcurator(object): | |
def add(self, first, second): | |
return int(first) + int(second) | |
if __name__ == '__main__': | |
args = parser.parse_args() | |
cli = Calcurator() | |
print(getattr(cli, args.mode)(args.first, args.second)) |
This file contains 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
import sys | |
import subprocess | |
script = sys.argv[1] | |
count = int(sys.argv[2]) | |
for _ in range(count): | |
proc = subprocess.Popen('python {} add 12345 67890'.format(script).split(), stdout=None) | |
proc.communicate() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment