Python-World / Python_and_the_Web

Build Bots, Scrape a website or use an API to solve a problem.
MIT License
684 stars 262 forks source link

Fix some antipatterns #654

Closed arnu515 closed 1 year ago

arnu515 commented 2 years ago

Description

Fixed some anti-patterns and best practices related to python.

Here's what I did: Replace for if statements with any(): The any function is a builtin python function that returns True if atleast one item in a list is True, and False otherwise. It makes the code more readable and is faster than using for-if condition

Use in [...] instead of multiple ==: In Python, it is recommended to use variable in [a, b, c, d] instead of saying variable == a or variable == b ... since it will be much faster, and more readable.

Type of change

Checklist:

Please tick all the boxes that are fulfilled by your Pull Request.