Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added final_task/pycalc/__init__.py
Empty file.
Empty file.
16 changes: 16 additions & 0 deletions final_task/pycalc/core/args.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
This module allows to work with command line arguments
"""
import argparse


def arg_parser():

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Согласно негласным соглашениям хорошим тоном считается давать функциям названия, выражающие действие (глагол). Название parse_args подошло бы лучше.
Кроме того, объем и сложность логики данной функции очень малы для вынесения в отдельный модуль. Обычно такую функцию называют _parse_args и располагают в модуле, являющемся точкой входа приложения.

"""
Parse arguments of command line
:return: arguments of command line
"""
parser = argparse.ArgumentParser(description='Pure-python command-line calculator.')
parser.add_argument('EXPRESSION', help='expression string to evaluate')
parser.add_argument('-m', '--use-modules', nargs='+', dest='MODULE', help='additional modules to use')

return parser.parse_args()
Loading