Learning Python
The Python programming language is used everywhere in this lab, the computational physics and biology communities, and big companies such as Google and Facebook. You don’t know Python? Start here to learn it.
Get started with the official beginner’s guide to Python and find the links that help you with your first steps, be it installation or any number of web resources for learning Python.
Beginners
If you are a beginner, I recommend
- Swaroop C H’s A byte of Python (a fairly extensive introduction)
- Software Carpentry’s Programming with Python
- my own Python Crash Course (which is a rough collection of essentials that I taught as part of the class Simulation approaches to Bio- and Nanophysics) or the slighly more refined Comp Methods in Physics: Introduction to Python
Intermediate
For people with programming experience (and anyone who passed through the beginner stage) I suggest the Python tutorial. You can also get a quick idea of the essentials from instant python.
Then start reading other people’s code and learn from them and keep the Python documentation handy. In case of questions and problems, StackOverflow and standard web searches are invaluable.
Python 2 or Python 3?
Python 2 (i.e. the 2.x releases of Python) is being slowly replaced by Python 3. Python 3 is cleaner and partially incompatible with Python 2 so there’s the question which version of Python should one use? A lot of code (especially in the sciences) still only exists as Python 2 or relies on Python 2-only libraries. Therefore, you should be able to read and write Python 2. However, the differences are not fundamental and by all means, learn Python 3 right away and then look up the differences to Python 2 when you need it.
More…
More sources that I found very useful
- Quantitative Economics is series of free lectures on quantitative economic modeling by John Stachurski and Thomas J. Sargent; it is an excellent introduction to Python and many of the outstanding scientific packages.
- Dive into Python and Dive into Python 3 is for people who already have experience with other programming/scripting languages
- Code Like a Pythonista :Idiomatic Python
- Performance python tells you how to make your python code faster (sometimes by a lot) and how to avoid some rather stupid (read: slow) constructs such as for-loops.
- Python Scripting for Computational Science, Hans Petter Langtangen. Texts in Computational Science and Engineering, Volume 3, 2008. Springer. DOI: 10.1007/978-3-540-73916-6 (free access to the PDF through the ASU Library — requires ASU login)
Discuss: “Learning Python”