kennethreitz/python-guide — pull request #101 by kevinburke (2012-03-13 07:16:10+00:00)
Title: Clean up the style page

Make a few changes to the style page to make it read better.

I was also thinking about adding some examples of the 'best' way to do some things like

```python
# Check if object is True
# bad:

if attr == True:
print 'It exists!'

# good:
if attr:
print 'It exists!'

# Try to retrieve object from dictionary
# Bad
if d.has_key('tree'):
fruit = d['tree']
else:
fruit = 'default'

# Good
fruit = d.get('tree', 'default')

# Get some items from a list
# Bad
b = []
for item in a:
if item < 5:
b.append(item)

# Good
b = [item for item in a if item < 5]
```