The Little Book of Python Anti-Patterns and Worst Practice
QuantifiedCode
Computers & Technology
The Little Book of Python Anti-Patterns and Worst Practice
Free
Description
Contents
Reviews

Welcome, fellow Pythoneer! This is a small book of Python anti-patterns and worst practices.

Learning about these anti-patterns will help you to avoid them in your own code and make you a better programmer (hopefully). Each pattern comes with a small description, examples and possible solutions. You can check many of them for free against your project at QuantifiedCode.

Read online.

Language
English
ISBN
Unknown
Why did we write this?
Who are we?
How is this book organized?
References
Licensing
Contributing
List of Maintainers
Index Of Patterns
Correctness
Accessing a protected member from outside the class
Assigning a lambda expression to a variable
Assigning to built-in function
Bad except clauses order
Bad first argument given to super()
else clause on loop without a break statement
__exit__ must accept 3 arguments: type, value, traceback
Explicit return in __init__
__future__ import is not the first non-docstring statement
Implementing Java-style getters and setters
Indentation contains mixed spaces and tabs
Indentation contains tabs
Method could be a function
Method has no argument
Missing argument to super()
Using a mutable default value as an argument
No exception type(s) specified
Not using defaultdict()
Not using else where appropriate in a loop
Not using explicit unpacking
Not using get() to return a default value from a dict
Not using setdefault() to initialize a dictionary
Maintainability
using wildcard imports (from ... import *)
Not using with to open files
Returning more than one variable type from function call
Using the global statement
Using single letter to name your variables
Dynamically creating variable/method/function names
Readability
Asking for permission instead of forgiveness
Comparing things to None the wrong way
Comparing things to True the wrong way
Using type() to compare types
Not using dict comprehensions
Not using dict keys when formatting strings
Not using items() to iterate over a dictionary
Not using named tuples when returning more than one value from a function
Not using unpacking for updating multiple values at once
Not using zip() to iterate over a pair of lists
Putting type information in a variable name
Test for object identity should be is
Using an unpythonic loop
Using map() or filter() where list comprehension is possible
Using CamelCase in function names
Security
use of exec
Performance
Using key in list to check if key is contained in list
Not using iteritems() to iterate over a large dictionary
Django
Maintainability
Security
Correctness
Performance
Migration to 1.8
The book hasn't received reviews yet.