Python is a fantastic programming language for the beginner (and everyone else too!). Here is a list of some resources I have found useful in my ongoing experience of learning how to program in Python.

Free Online Tutorials

  • Official Python Website has information for beginners and links for downloading python itself (although if you have a mac or linux/unix/etc it may already be installed!
  • Learn Python the Hard Way emphasizes general-purpose programming skills and has a somewhat sarcastic tone.
  • Codecademy focuses more on web development and has a more friendly tone.

Books

  • Learning Python by Mark Lutz is the book I used myself to learn python. It is very long and goes into probably more detail than the beginner would need about object-oriented programming. There may be other books that are better but this is the only one I am personally familiar with.

Text Editors

This is what you use to write the python programs!

  • IDLE is what I used when I first started. It is included when you download python itself.
  • Text Wrangler is what I currently use on macs
  • Notepad++ is what I currently use on windows machines.
  • If you want to impress your friends, and/or do things on remote servers such as in the Amazon cloud, check out the command line based text editor called Vim. It’s a bit tricky and not recommended for beginners. Vim Tutorial

General Programming Resources

  • Command Line Crash Course is a good quick tutorial on basic shell commands, which are handy in executing python scripts and many more things as well
  • Github is a social, open-source focused platform for hosting code. I highly recommend using git or some other version control system in all programming projects. Feel free to take a look at my personal python sandbox here.
  • Bitbucket is a good alternative to github if you need private repositories
  • Stack Overflow is a question-and-answer site for any programming topic. If you run into difficulties it’s an excellent place to go for answers
  • Although it is controversial, I admit to having used the w3schools SQL tutorial. Understanding SQL is essential to dealing with most databases, a task that will likely come up eventually in one’s programming life

Python Tools

Once you are familiar with basic programming in python, you will find yourself wanting to leverage third party libraries and advanced tools. Here are some cool things to check out.

  • PIP is a package manager for installing third party libraries rapidly from the command line. It also manages dependencies (installs automatically all packages that your package needs to run). It’s not the smoothest thing to install but is very useful once you have it. Here are some packages I recommend (feel free to look them up, I will maybe add links later):
    • pandas, numpy, scipy, and matplotlib for scientific computing (especially statistics and linear algebra) and graphing. These are probably easier to install from the official websites than from pip since they have a lot of fortran and C dependencies.
    • httplib2 for HTTP requests
    • oauth2 for dealing with authentication when interacting with certain application programming interfaces (APIs)
    • simplejson for parsing JSON, a common data transfer language in many APIs and web services
    • nose for automated unit testing (testing your own code)
    • selenium a way to programmatically control a browser through “web-driver” commands (eg, for testing someone else’s website)
    • web.py is a web framework I have used to make a dynamic web site. Django is another popular one but I haven’t tried it personally.
    • cx_Oracle is useful if you need to interact with Oracle databases. It’s hard to install via pip due to complicated C dependencies, so just download the installer from their website instead.
    • sqlite3 is useful for working with SQLite databases. Be careful about the versioning though (it’s easy to confuse the version of the python package and the version of the SQLite database and install the wrong one).
    • xlrd is good for extracting data from Microsoft Excel files
  • iPython is a handy interactive shell with a lot of interesting features
  • iPython Notebooks are a great way to present projects that include code, graphs, mathematical formulas, and other heterogeneous content in an organized fashion. They are similar to the popular Rmarkdown documents in the R statistical computing language.
  • If/when you want to create your own python packages, be sure to check out Virtual Environments for testing the deployment process on your local machine. This is more for advanced users.

Programming Challenges

I have enjoyed trying to solve problems on the following sites as a fun way to build up my programming skills:

  • Project Euler is a puzzle site focusing on mathematical challenges that can be solved with programming. It will help you improve the speed and efficiency of your code. You might need to look up some topics about number theory from time to time.
  • Rosalind is a bioinformatics learning site with great interactive practice problems for learning python

MOOC Sites

This isn’t particularly python-related, but if you want to keep learning more about programming (or really anything else for that matter), the following massive online open course (MOOC) sites are recommended:

  • Coursera is one I have used myself. The Machine Learning class is particularly famous and worth trying.
  • Udacity I haven’t tried but it seems to focus more on practical skills like entrepreneurship than academic topics
  • EdX seems to be similar to Coursera except maybe is less strict about deadlines for course assignments
  • Khan Academy is a friendly site with a lot of nice videos about high-school and college level subjects (eg, if you need to quickly review a particular topic in calculus or basic programming)

I hope these lists of resources were helpful for you. If you think of any that I missed and you realy like, feel free to add a comment and I’ll try to update the post to benefit future readers.

Last night I was reading through Hello World!, an introductory programming book loaned to me by a coworker, and decided to give Python a crack. Here’s my first attempt. Just paste it into a text editor and save as ‘lat2dms.py’. Then run it in IDLE GUI (free download) with F5. If you type lat2dms(###) in IDLE it will convert the decimal degree value ‘###’ to degree-minute-second format (four outputs, including N/S to indicate direction). I originally wrote it to output a concatenated string of those values but couldn’t figure out how to include the degree, minute, or second symbols (eg ‘ and ”). My ultimate goal is to use this as a building block for a script that will import a CSV file with geodata  in one format and output a new CSV file with the same data in a different format, suitable to be used with Excel or any compatible geographic information system. I’m about halfway through the loops chapter, so hopefully that will come in handy. This has been a fun exercise and I hope I can continue learning on the side.

#this is a program to convert a decimal latitude value into degrees minutes seconds format
#by Will Townes 25 AUG. 2009
#https://willtownes.wordpress.com

def lat2dms(ilat):

#this conditional defines whether the lat. is north or south
    if ilat>=0:
        direction = 'North'
    else:
        direction = 'South'

    ilat = abs(ilat)

#here we parse the initial, decimal value into degrees minutes and seconds.
    degrees = int(ilat)
    rawminutes = 60*(ilat-degrees)
    minutes = int(rawminutes)
    seconds = int(60*(rawminutes-minutes))

    if ilat > 90:
        print "ERROR- invalid latitude value. Please enter a value between -90 and 90."
    else:
        print "(degrees, minutes, seconds, direction)"
        return degrees, minutes, seconds, direction