Send mail to the author(s) E-mail

# Sunday, 24 June 2012
( Python )

From the very good video on youtube: python google

alt P in IDLE is previous command

How to Run a Python Script

#!/usr/bin/python2.4 -tt
# Copyright 2008 Google Inc.

# Define a main() function that prints a little greeting
def main():
  print "Hello"
# This is the standard boilderplate that calls the main() function
if __name__ == '__main__':

2 ways of running the python program

Import a Module

# sys is a module which lets you access lots of command line stuff, system stuff
import sys

# Define a main() function that prints a little greeting
def main():
  print sys.argv


Prints out a python list which has square brackets around it.


when we forget to do the import.

import takes the symbol sys, and binds it to something.


import sys

def Hello(name):
  if name == 'Alice' or name == 'Nick':
    print 'Alert: Alice Mode'
    name = name + '???'
  name = name + '!!!!'
  print 'Hello', name

# Define a main() function that prints a little greeting
def main():


Python does everything at the last possible second, so no compile time checking.. just runs the code.  So if it doesn’t actually see the error line, it wont catch anything.

what this means is that unit testing is important for industrial strength code.


strings are immutable

a.lower()  - this brings back a new string lowered.  a is unchanged.

a string method.

a.find(‘e’) – searches in the string for the first e.  returns index of first e.

a[0] – prints left most character

a+b – concats

‘Hi %s I have %d donuts’ %(‘Alice’, 42)

Unicode got better in Python3.

a[1:3] – up to but not including.  A slice in python.  A very pythonic feature – short and crisp!

can also use negative numbers which start at the right of the string

a[:-3] – not the last 3 characters of the string.

| | # 
# Saturday, 23 June 2012
( Python )

Created in 1990 by Guido van Rossum who now works at Google.

Supports OO and structured programming.

“A quick and light language”

Doesn’t have a really heavy type system.  Similar to Ruby, Perl, bash to download windows installer

good easy video tutorial:


should have been print (“Hello World”)

google python – python game book – invent games in python… looks good!

Hello World

print (“hello world”)  - as I’m using python 3.x


and back to 2.7


Example Games in Pygame


first successful game running in Python.


another game from pygame which includes multiplater and a server.

image – looks like a good games tutorial


| | #