SmoothFriction.nl

posts - 39, comments - 20, trackbacks - 0

Sunday, July 04, 2010

Python 101: Setting up

One of the first things I do when getting started with a new programming language is to find myself a good development enviroment. I love Visual Studio, and I love the things Jetbrains does (ReSharper, IntelliJ IDEA). Visual Studio can work with python, in the appearance of IronPython. However, I want to go straight to the bone first and start out with the ‘original’!

JetBrains recently launched a new line of editors: a web editor, one for PHP, and… One for Python! PyCharm comes with everything you’re used to have in IntelliJ IDEA, combined with all the goodness of Python. I’d say that’s reason enough for me to try it out, now is it? Either way, first of all getting started with Python: the bare way. Trust me, it couldn’t be simpler!

Setting up Python

  1. Navigate your browser to www.python.org.
  2. Find the download button.
  3. Download your preferred package (at the time of writing, I picked the windows installer for 2.6.5).
  4. Install/unpack!
  5. Done.

See? That wasn’t all too hard. To test it out, you can either use the interactive command line, or simply write a small program to test it. Here’s a small sample program:

def test_function(input):
    print input

if __name__ == "__main__":
    test_function("hello world")

To run this, all  you have to do is drop it on your python.exe or run python.exe <insert-filename-here>. You should see ‘hello world’ printed out on your screen!

Setting up PyCharm

Once again, this couldn’t be any simpler (well, except for not installing this IDE). First, execute the steps for setting up Python. You’ll need that environment before you do anything else. After you’ve done that, you’re supposed to point the IDE to the installed Python framework. To do this, you go to File –> Settings, select Python Interpreter from the list and add an entry pointing towards your installation folder.

Once again, to see if everything is working, you should create a new project, add a file (test.py) and then set up some stuff to get a valid configuration to run the script:
First, you go to Run –> Edit Configurations. Add a configuration, and select your script. Once you save this, it will be available to run via the play button on the toolbar.

Alright, that’s all you need to know for now. Next time I’ll share my first experiences with Python, it’s dynamically strong typedness and perhaps something completely different!

posted @ Sunday, July 04, 2010 10:49 AM | Feedback (0) |