-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Denis Petrovsky #20
base: master
Are you sure you want to change the base?
Denis Petrovsky #20
Conversation
final_task/Calculate.py
Outdated
|
||
|
||
def calculating(expression): | ||
def parse(expression): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Для чего функции реализованы внутри другой функции?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Исправил
final_task/Calculate.py
Outdated
elif func and func in math_const: | ||
yield math_const[func] | ||
|
||
def infix_to_postfix(parsed_formula): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
я насчитал 10 yield
конструкций на два генератора. Мало того, один генератор использует другой. В этом очень сложно разобраться. Желательно должен быть один return/yield в функции/генераторе.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Исправил
файлы с байткодом ( |
final_task/Calculate.py
Outdated
def infix_to_postfix(parsed_formula): | ||
"""This function translate infix form into postfix form""" | ||
stack = [] | ||
for token in parsed_formula: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Крайне похожее решение у Yury Kuznetsov @WFLM
местами код совпадает символ в символ
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Брал за основу статью с хабра
Если её переделать "под себя" и добавить поддержку математических функций и всего остального, что требуется в ДЗ, так нельзя?
Signed-off-by: Denis Petrovsky <[email protected]>
Почти полное копирование кода из статьи: https://habr.com/ru/post/273253/ |
Signed-off-by: Denis Petrovsky <[email protected]>
|
||
import re | ||
import core | ||
from constants import * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
импорт через звездочку -- это зло
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Даже из собственного модуля, где лежат одни только константы?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Да, даже из своего модуля.
def check_brackets(expr): | ||
"""Get expression. Check brackets balance""" | ||
if expr.count('(') != expr.count(')'): | ||
print("ERROR: brackets are not balanced") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Для этого лучше использовать исключения
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Спасибо за фидбек, постараюсь учесть все ошибки и в будущем так не делать
return function(*list_of_arg) | ||
|
||
|
||
def comma_count(function): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
а что, если у функции нет докстринга?
@@ -0,0 +1,125 @@ | |||
from constants import * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
импорт через звездочку -- это зло
|
No description provided.