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
[X] Bug fix (non-breaking change which fixes an issue)
[ ] New feature (non-breaking change which adds functionality)
[ ] Documentation Update
Checklist:
Please tick all the boxes that are fulfilled by your Pull Request.
[X] I have named my files and folder, according to this project's guidelines.
[X] My code follows the style guidelines of this project.
[X] My Pull Request has a descriptive title. (not a vague title like Update index.md)
[X] I have commented on my code, particularly in hard-to-understand areas.
[X] I have created a helpful and easy to understand README.md, according to the given README_TEMPLATE.
[X] I have included a requirements.txt file (if external libraries are required.)
[X] My changes do not produce any warnings.
[X] I have added a working sample/screenshot of the script.
Description
Fixed some anti-patterns and best practices related to python.
Here's what I did: Replace
for if
statements withany()
: Theany
function is a builtin python function that returnsTrue
if atleast one item in a list isTrue
, andFalse
otherwise. It makes the code more readable and is faster than using for-if conditionUse
in [...]
instead of multiple==
: In Python, it is recommended to usevariable in [a, b, c, d]
instead of sayingvariable == 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.
Update index.md
)README.md
, according to the givenREADME_TEMPLATE.