Skip to content

Commit 5f5faff

Browse files
implementation9
1 parent d2fca8b commit 5f5faff

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

final_task/pycalc/__main__.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,22 @@ def createparser():
1717
parser = argparse.ArgumentParser(prog='pycalc', description='pure Python command line calculator',
1818
epilog="""Anton Charnichenka for EPAM: Introduction to Python
1919
and Golang programming, 2018.""")
20-
parser.add_argument('expression', nargs=argparse.REMAINDER, help="""mathematical expression string to evaluate;
20+
parser.add_argument('expression', help="""mathematical expression string to evaluate;
2121
implicit multiplication is supported""")
2222

2323
return parser
2424

2525
def main():
2626
"""calculation chain"""
2727
parser = createparser()
28-
main_input, spare_input = parser.parse_known_args(sys.argv[1:])
28+
namespace = parser.parse_args(sys.argv[1:])
29+
user_expr = namespace.expression
30+
#main_input, spare_input = parser.parse_known_args(sys.argv[1:])
2931
# get user's expression
30-
if main_input.expression:
31-
user_expr = main_input.expression[0]
32-
else:
33-
user_expr = spare_input[0]
32+
#if main_input.expression:
33+
#user_expr = main_input.expression[0]
34+
#else:
35+
#user_expr = spare_input[0]
3436

3537
# calculation chain
3638
# tokenize user's expression string

0 commit comments

Comments
 (0)