V
V
Valery2021-06-25 01:07:53
Python
Valery, 2021-06-25 01:07:53

Could you rate my Python code?

Could you rate the code of my project, which I did for the final qualifying work.
I would like to hear what things you should pay attention to, how to improve your code.
GitHub: https://github.com/ApXNTekToP/MerchTelegramBot
You can test the bot here: https://t.me/testmerchant_bot
Thank you for your attention!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2021-06-25
@ApXNTekToP

Looked out of the corner of my eye
1. routing.py: replace the regular expression with something more readable, for example: 2.main.py: class Register: move the compilation of the regular expression to the beginning of the code:if 'some' in text:

import re

MY_RE = re.compile(f'some pattern')

class Register:
user_response = MY_RE.findall(self.text)

3. don't wrap large pieces of code in try-except
4. Make an effort on yourself and give up global
5. This is something terrible:
# Keep main program running while bot runs threaded
if __name__ == "__main__":
    while True:
        try:
            sleep(120)
        except KeyboardInterrupt:
            break

6. Use f-strings instead of format
7. Why does a class inherit a class method? 8. Make functions shorter, let there be more of them than such sheets
class InterfaceInteraction(classmethod):

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question