Archive

Posts Tagged ‘tutorial’

Getting started with Python (part 6 – for newbs)

August 10th, 2009 No comments

Loops are another “flow control” tool, like an if statement. Loops allow you to repeat the same piece of code multiple times, which can be very useful when you are processing data.

There are two types of loops in Python, the for loop, and the while loop. The for loop is one of the easiest ways to process data. Let’s take a look:
Read more…

Categories: Uncategorized Tags: ,

Ruby On Fail

August 9th, 2009 No comments

The documentation for setting up a web server for RoR (Ruby on Rails) on Windows is really lacking. Figuring out what server software you’re supposed to use is probably the hardest part. Should you use Apache or IIS as the web server? How are you going to connect it to Ruby? CGI, FastCGI, fcgid, Mongrel, mod_ruby, passenger (aka mod_rails / mod_rack) or WEBrick (not recommended for production use)?

If you pick a combination that doesn’t work properly on Windows, you can spend hours (as I did with mod_fcgid) trying to figure it out.

The solution that worked for me was setting up Mongrel (which is a Ruby web server) as a service, and using Apache to proxy Ruby requests to Mongrel.

Here’s a step by step tutorial:
Read more…

Getting started with Python (part 5 – for newbs)

August 5th, 2009 No comments

Continuing from tutorial 4, we’ll discuss object oriented programming, classes, and how OO is applied in Python.

First of all, if we’re not doing object oriented programming, what kind of programming are we doing? Most likely, procedural. Procedural programming uses multiple functions to accomplish a task. Object oriented programming is the idea of packaging related variables and functions together in a reusable container called a class. Technically, OO is about modeling real world objects.
Read more…

Categories: Uncategorized Tags: ,

Getting started with Python (part 4)

August 2nd, 2009 No comments

In this tutorial, I’ll explore the Python interactive shell, IDLE, and how to use the interactive shell from PyScripter.

The interactive Python shell is basically the Python interpreter, running on code that you enter directly into it, as opposed to when you run a script and the input comes from a script file.

The shell is very useful for testing theories without the hassle of creating a script file, modifying it, running it, editing again, running it again, etc.

You can bring up the shell in a command prompt, but I prefer to use IDLE, which is the IDE that comes with Python. I think PyScripter is better, in terms of project management, debugging, and editing.

As an interactive shell, IDLE is pretty good.

Read more…

Categories: Uncategorized Tags: ,

Getting started with Python (part 3 – for newbs)

August 2nd, 2009 No comments

In this tutorial, I’ll go over some of the basic concepts of programming, and how to use them in Python.

Keep in mind that having good reference material is important. The Python documentation, and some of the free Python books can be very helpful.

Starting with the basics, what is a program? A program is a collection of steps to accomplish a task. Technically, that’s true for every program that was ever created.

You’ll probably see Python programs referred to as “scripts”. Programs and scripts are in a way, synonyms. Both are a collection of steps to accomplish a task. However, scripts sometimes depend on, or are run by other programs. Scripts are usually stored in plain text, and are run by an interpreter. Programs are usually compiled (into a intermediate language, or directly to machine code).

Read more…

Categories: Uncategorized Tags: ,

Getting started with Python (part 3 – for programmers)

August 1st, 2009 No comments

In this tutorial, I’m going to go over writing your first Python program for C style language developers.

In most C style languages, a program starts execution in a main function. Python is a little different. To allow Python programs to act either as runnable programs, or as modules (similar to a class library), there’s a special way that you call the main function (source). In fact, it doesn’t have to be called main at all; you can name it whatever you want.

Read more…

Categories: Uncategorized Tags: ,

Getting started with Python (part 2)

July 30th, 2009 No comments

In this tutorial, we’ll discuss learning Python from a C style language developer’s perspective.

C languages are, by design, very strict. You either do it their way, or your code won’t compile.

Python is the polar opposite of C languages. It takes a “we’re all consenting adults here” attitude, and let’s you do pretty much whatever you want.

Python is also built for speed. Not speed of execution, but speed of coding. It’s a great language if you want to throw a script together in a half hour.

Read more…

Categories: Uncategorized Tags: ,

Getting started with Python (part 1)

July 28th, 2009 No comments

When I wanted to start programming with Python, like most programmers, I looked for an IDE of some kind. All the results I found seemed to have a list of dependencies, none of which I knew anything about. After a few hours, I decided to forget it.

A few months down the road, I came across a neat package called Portable Python. This package had a Python distribution, two IDEs and some libraries, all configured and ready to go. At the time, I didn’t have any new programming projects planned, so I filed the link in my bookmarks.

About a week ago, I finally had a project I could try in Python. I downloaded Portable Python, and got to work. After a few hours in the Python docs, I completed the script.

The only problem with the above solution was that it wasn’t a normal Python distribution. Installing libraries would be difficult at best. I decided that I needed to have a regular Python distribution, with all the functionality that I was getting from Portable Python.

After a few hours, I had completed my goal. Hopefully, the below tutorial will save you a few hours.
Read more…

Categories: Uncategorized Tags: ,