Python Best Practices- Part 1

--

Writing Better Code

PEP 8

Flake8 is the wrapper which verifies pep8, pyflakes and circular complexity.

Here’s an example you might see when you run flake8:

Explicit is better than implicit

Sparse is better than dense

Errors should never pass silently

Function Arguments

Checking for equality

Accessing Dictionary

Manipulating lists

Long line code

Unpacking

Closing Resources

Importing Modules

Decorators

Decorators are used to add functionality without disturbing the existing functionality. The below example calculates the time taken to execute the method.

It’s all about Writing Great Code..

Thanks for reading!

Part 2 will be added soon..

--

--