joelgrus / data-science-from-scratch

code for Data Science From Scratch book
MIT License
8.63k stars 4.5k forks source link

Please add a new comment about `from __future__ import division` #5

Open iphyer opened 9 years ago

iphyer commented 9 years ago

Please add a new comment about from __future__ import division

When someone is new to Python and he follows your directions step by step then he wiil find his is trapped by the book code sample like this:

from __future__ import division # integer division is lame

This statement must be put at the head of the code

num_users = len(users)   # length of the users list
 avg_connections = total_connections / num_users # 2.4

That will be more useful and clear and it will be convenient for people to follow your code step by step.