Showing posts with label setup. Show all posts
Showing posts with label setup. Show all posts

Wednesday, January 15, 2014

Week 0: Installing and Coding Python on Your Own Computer

You can code in Python on at the very least the 3 major operating systems (Mac, Windows, Linux) - I make no guarantees about Android, FirefoxOS, or ChromeOS. To effectively write code in Python, you need three things installed on your computer:

  1. The Python interpreter, or the program that will run the Python code you write
  2. A place to write your Python code, like a text editor or something fancier
  3. Something that can help you install interesting Python packages in the future (this is called a package manager
If you use OSX or a flavor of Linux, you already have the Python interpreter installed on your computer, and you have some kind of text editor to write your code in. If you have Windows, you need to install the Python interpreter no matter what. My recommendation for beginners is to install an IDE (integrated development environment) to write your code in. It is very common for Python-specific IDEs to come pre-packaged with Python, so all you need to do is install the IDE and start coding. The main difference between an IDE and a regular text editor is that an IDE gives a few more tools to the programmer - for example, you do not need to compile and run your code from a terminal if you use an IDE. The choice to use one is up to you, and I encourage you to try out a few different ways of writing Python code to see which one you like better.

I am not going to tell you about package managers for Python yet, but eventually you will need to install one to install interesting Python libraries to play with.


A Possible IDE for Python:

There are many options for IDEs / text editors that you can use - some more customizable, some more package-friendly, some more interactive, some more "hardcore". The long story short is that it doesn't matter what IDE / text editor you use, as long as you have Python installed on your system and you know how to use it. I have listed a number of IDEs / editors here that you can use. The one I recommend for beginners is Enthought Canopy, just because it automatically installs Python, a pretty decent IDE, and a bunch of mathematical packages that are annoying to install manually. The same goes for Anaconda. But ultimately the choice is yours.

The IDE you choose is totally a matter of preference. If you are just starting, I recommend using one of the standard packaged IDEs - Enthought, Anaconda, IDLE, and switching between them. Try all of them and decide which one you like best. You might get to the point where you want to optimize your keystrokes or find yourself doing the same type of operation over and over again. But for 95% of ordinary users, these packaged IDEs work fantastically. Try one out, but be flexible. The only thing you should never do is pay for an IDE - there are plenty of free ones out there that work great, so don't pay for something until you're sure it's what you want.
What do I use, personally? On my Windows machine I have Enthought Canopy, on my Linux machine I use Sublime Text 3, and on a Mac I use Sublime as well. But I used to be a heavy IDLE user when I first started with Python.

Python 2 or Python 3:

You might have heard some of your coder friends talking about this new "Python 3" movement. The short story is this: Python 2.7 has been the industry standard for years, but there were a few major annoyances that caused developers problems. Python 3 was released in late 2008 and has been continuously improved ever since, but it is not yet up to speed with industry standard. The main problem is "legacy libraries" and "legacy code", that is, code / packages that were written back in the Python 2.7 days that were not translated into Python 3. 

Because you are most likely not maintaining legacy code with Python, the recommendation is to learn Python 3 - it is the future of Python, and packages are slowly being ported to Python 3. All the exercises I will post here will assume you have Python 3 installed.

Exercises: 

  1. Install Python 3 and an IDE / text editor of your choice
  2. Figure out how to open it, where to run your code from, and where the output of your code will be. Usually you can figure this out by reading the website of the product, watching YouTube videos, or searching the internet.