Code for the book “Machine Learning: An Algorithmic Perspective” by Stephen Marsland: http://seat.massey.ac.nz/personal/s.r.marsland/MLbook.html; http://seat.massey.ac.nz/personal/s.r.marsland/Code/MLcode.zip
Although it’s a bit outdated it still contains a good examples of Python code to hack on, as advised here: https://www.quora.com/What-are-good-books-on-advanced-topics-in-Python
Another interesting book to learn Python from data science perspective:
Think Python: How to Think Like a Computer Scientist [Direct link to PDF] [Source code]
Good book on Python for beginners (as advised here: What are the best books to learn Python quickly, for an experienced C++/Java programmer?):
A Byte of Python – free book on programming using the Python language. It serves as a tutorial or guide to the Python language for a beginner audience. [Web site] [free PDF download (creative commons license)]