Site Map - skip to main content - dyslexic font - mobile - text - print

Hacker Public Radio

Your ideas, projects, opinions - podcasted.

New episodes Monday through Friday.

The passing of FiftyOneFifty

It is with deep sadness we announce that another of our hosts and friends Donald Grier, known to us as FiftyOneFifty, has passed away.

FiftyOneFifty's frat brother Randy Hall has written an lovely piece. The team at Linuxlugcast are preparing our own tribute if you want to contribute an audio file you can email Honkeymagoo or join the show.

Our thoughts go out to his friends and family at this difficult time.

In-Depth Series

Programming 101

A series focusing on concepts and the basics of programming

hosting software in HPR show notes - Jezra | 2019-10-10

#!/usr/bin/env python
import urllib.request
import json
import re
import subprocess

# see

#where are we? GPS coordinates
lat = 39.275235
lon = -120.9199507
#what is the user agent string?
agent = "Jezra's fun lil script"
#minimum wind speed in mph?
min_speed = 9

def get_api_data(endpoint):
  #prepare the connection with custom headers
  request = urllib.request.Request(endpoint, headers={"User-Agent":agent})
  #create a handler for the request
  handler = urllib.request.urlopen(request)
  #get the text
  text =
  #parse the json text to a python object
  obj = json.loads(text)
  return obj

def wind_is_good(s):
  #use regex to find the matches
  matches = re.findall("[0-9]+",s)
  for match in matches:
    #convert string to int
    m = int(match)
    #is the speed good?
      return True
  #if we get here, there is no match :(
  return False

start_url = "{0},{1}".format(lat,lon)
#get the json response from the start_url as a python object
obj = get_api_data(start_url)

#get the forecast url from the returned data
forecast_url = obj['properties']['forecast']

# process the forecast url
forecast = get_api_data(forecast_url)

#loop through the forcast periods
for period in forecast['properties']['periods']:
  #put name and windspeed into easier to handle variable names
  name= period['name']
  wind = period['windSpeed']
  print (name, wind)
  #check the wind speed
  if wind_is_good(wind):["textjezra","{0}: {1}".format(name,wind)])

Telling myself something In The Morning - Jezra | 2019-07-11

Processing - klaatu | 2018-07-31

Get Processing from Download, extract, and launch. On Linux, just click the processing file.

Processing requires that either OpenJDK or Java to be installed.

Processing requires a void setup() function, which is a function that Processing expects whenever an application is launched. If you don't have a setup function, your application still launches, but with basic Processing defaults. Try this to start with:

void setup() {

Click the Run button in the top left corner to launch your [very simple] application: an empty window that is 480 pixels wide and 720 pixels tall.

Draw a rectangle on your canvas by invoking Processing's void draw() function:

void draw() {

Click the Run button in the top left corner to launch your application.

Add some colour to your rectangle:

void draw() {

Click the Run button in the top left corner to launch your application.

Make a simple painting app:

void setup() {

void draw() {
    if (mousePressed) {
    } else {

More Processing tricks: you can export your application as a standalone Java app, or as an Android .apk as long as you have the Android SDK installed.

Processing's documentation is excellent. It has examples for all functions, with pictures.

Follow on to HPR2340 (Tracking the HPR queue in Python) - MrX | 2017-07-27

This is a follow up to my previous show HPR2340, the improvement being I use the available STATS file from the hpr website rather than scraping the content from the HPR calendar page

Snapshot contents (2017-06-23) of 'stats.txt' file which was actually called 'hpr_stats.txt' my mistake

Started:    11 years, 8 months, 19 days ago (2005-10-10)
Renamed HPR:    9 years, 5 months, 27 days ago (2007-12-31)
Total Shows:    2911
Total TWAT: 300
Total HPR:  2611
HPR Hosts:  286
Days to next free slot: 17
Hosts in Queue: 9
Shows in Queue: 14
Comments waiting approval:  0
Files on the FTP Server:    1
Number of Emergency Shows:  7
Days until show without media:  0
#!/usr/bin/env python3

### This is a scratchpad file I've created to try out snippets of code in python

# The script below is for use with Python 3
# This script should work out of the box on most systems running a version of Python 3 
# If you happen to have a blinkstick lying about then your can uncomment the blinkstick module
# and uncomment the references at the bottom of the program that call the blinkstick functions
# Regrds, Mr X

# Imported modules
from time import sleep          # used to pause program
#from blinkstick import blinkstick  # used to control blinkstick nano attached to usb port of raspberry pi
import urllib.request           # used to capture hpr webpage content to get the number of HPR shows in the que
import re               # regular expressions, used to find sting in HPR webpage (get_hpr_que)

# These functions control a blink stick nano attached to my raspberry pi USB port #################
# They can be ignored or deleted if you don't have one

def bstick_off():
# Search for all attached blinksticks and turn them all off
    for bstick in blinkstick.find_all():
        bstick.turn_off()   # Turn front blinkstick LED off
        bstick.set_color(channel=0, index=1, name="black")  # Turn rear blinkstick led off
        print("Blinkstick: " + bstick.get_serial() + " turned off")

def bstick_on(colour):
# Turn blinkstick on and set led colour to string value stored in var colour
# valid colours are, black, silver, gray, white, maroon, red, purple, fuchsia, green, lime, olive, yellow, navy, blue, teal, aqua
    for bstick in blinkstick.find_all():
        bstick.set_max_rgb_value(30)        # Sets max blinkstick RGB value to 15, makes LED dimm
        bstick.set_color(name=colour)       # Turn blinkstick on, var colour determines colour
        print ("Blinkstick: " + bstick.get_serial() + " | Colour: " + bstick.get_color(color_format="hex") + " [" + colour + "]")

def bstick_on_random():
# Turn blinkstick on colour random
    for bstick in blinkstick.find_all():
        print ("Blinkstick: " + bstick.get_serial() + " | Colour: " + bstick.get_color(color_format="hex"))

def bstick_blink_red():
# Flash blinkstick colour red
    for bstick in blinkstick.find_all():
        print ("Blinkstick: " + bstick.get_serial() + " | Colour: " + bstick.get_color(color_format="hex"))


def get_hpr_que_improved():
# Goto hacker public stats page and extract the number of days to next free slot
# turns on blinkstick LED with colour dependent on the number of days to next free slot in HPR queue

    url = ''  # HPR url for stats page
        text = urllib.request.urlopen(url).read()   # Try to read hpr stats text
        print("ERROR: Problem acessing url " + url)     # if error accessing url then return -1
        hpr_shows = -1
        return hpr_shows
    #print(text)    # DEBUG
    text_page = str(text)   # convert text from list to string
    line_begin = text_page.find('Days to next free slot:') # find position of string in page
    line_end = line_begin + 27 # Store line end position (start position + 27)
    line = text_page[line_begin:line_end]  # Capture string line
    #print(line) # DEBUG Print line string
    digit = re.findall(r'\d+',line)         # Find digits in line
    #print(digit[0])    # DEBUG print the 1st digit
        hpr_shows = int(digit[0])   # convert digit list to integer days
    except:                         # If show numbers not found then return -1
        print("ERROR: Problem getting number of HPR shows in que.")
        hpr_shows = -1
        return hpr_shows

    if hpr_shows > 9:       # If hpr show que > 9 turn on green LED
        print("Turn on green blinkstick LED")
    elif hpr_shows > 5:     # Else if hpr show que > 5 turn on blue LED
        print("Turn on blue blinkstick LED")
    elif hpr_shows > -1:    # Else if hpr show que > -1 turn on ref LED
        print("Turn on red blinkstick LED")     
        print("Flash red blinkstick LED")
        #bstick_blink_red() # Else blink LED to show error
    print("The are " + str(hpr_shows) + " days to tne next free slot in the HPR que...")
    print("Turn off all blinkstick LED's")
    #bstick_off()           # Turn blinkstick off

# Main program

A Mouse in a Maze on the Raspberry PI - Gabriel Evenfire | 2015-09-17

This podcast is about a little programming exercise I learned in my first programming class. The idea is to generate a random text-based maze and make mouse ('@') search the maze systematically to find the cheese ('V'). If it does so before it runs out of energy (moves) it wins ('$' == happy mouse). Otherwise it starves ('%' == dead mouse).

You can find my git repos for the Raspberry PI code including this program at these locations:

The Mouse-in-a-maze program also requires the catlib library as well which is at:

You may note that these directories are different from those in my previous RPI episodes. The repositories used to be on gitorious. However since gitlab acquired gitorious, I have migrated the repositories. They currently live on both github and gitlab and I have pushing updates to both for the time being. So I have been waffling about which one will be the ultimate master for these projects. But since, I am doing most all the work on this code myself, it doesn't much matter for the time being.

If this is your first time playing with bare metal programming in the RPI you can get more info and tips from HPR episodes 1619, 1630 and 1666. Note that the gitorious links in those episodes are outdated as mentioned above. The github links therein should still be fine though.

The mouse code itself is in the apps/mouse0 directory. If you haven't played with this environment before you'll need to do the following:

  • Get a compatible ARM toolchain up and running to build for the RPI. I recommend using:
  • You'll need a USB-to-TTL serial cable to hook up to the RPI. I use:
  • You'll also need a small SD card to boot from.
  • Follow the steps in catrpi/README.txt to
    • create an SD-card with a loader on it.
    • build catlib for the RPI locally (a prereq for building mouse0.bin)
    • set up your serial connection to the RPI
    • start up a minicom instance to connect to the RPI

Once those prerequisites are taken care of you can:

  • change directory to /path/to/catrpi/apps/mouse0 type make to build
  • mouse0.bin power on the RPI at the loader prompt, type 'x' in the
  • serial console to start X-modem reception on the RPI
  • use your terminal program to send the mouse0.bin file via X-modem. In minicom you do this by CTRL-A followed by 's'. You then select 'xmodem' as the protocol and navigate to and select the file mouse0.bin to send.
  • when the transfer completes type 's' to start the program

These pages describe VT100 Terminal codes:

Sample traversal:

  #+0****## #+#...###...#..$ ##  #  #    #
  ##+###+## #+++......#...# ##       #   #
  # #.+++++#....#   #      #    #      # #
  #  #+++++#+.+..#  #  #          #      #
  #  #.##.+++#+.### #     #   #   ##     #
  #  ###.+.##++.##     #   ###     #   # #
  ####+.#..#++#.##   #      #####   ##   #
  #++#.#.###+.##    ##       ##    #   # #
  #++++++.##.++.#   #  ##     #  # #  # ##
  #+++++#..##.##      ## #  #### # #    ##
  #+.....#..#.  ##   #      #     ##  ## #
  #+..+.......   # #      #      #  ##   #
  #+...#..###       # #  #          ##  ##
  #.#..#.........# # # # ##### # #    ## #
  #.......##  ##....  #        ###   ##  #
  ##......# ##   ##..#  #####          # #
  #.+.#...###    ###. ##          ##  # ##
  ##.+...#  #      ####      #   ##    # #
  Mouse found the cheese!  :)  Press any key to restart!

An Intro To C Episode 1 : Introduction and Types - cjm | 2015-05-13

Episode 1: History and Basic Types

Explain who you are and what you do.

  • Name: Colin Mills, (cjm)

  • Occupation: Software Engineering Student in Canada

  • I have been a UNIX geek and open source software FANATIC for about four years now.

  • Website:

Start to go into the history of C and explain where it came from.


C was originally developed by Dennis Ritchie between 1969 and 1973 at AT&T Bell Labs,[5] and used to (re-)implement the Unix operating system.[6] It has since become one of the most widely used programming languages of all time, [7][8] with C compilers from various vendors available for the majority of existing computer architectures and operating systems. C has been standardized by the American National Standards Institute (ANSI) > since 1989 (see ANSI C) and subsequently by the International Organization for Standardization (ISO).

Explain Types and their meanings

  • SIGNED: It means it can hold either negative or positive values.

  • UNSIGNED: Unsigned means it can only hold positive values.

Retrieved From: Wikipedia On Signedness


  • An int is a variable that is at leas 16 bits in size.

  • It is actually the most efficent for the processor itself.

  • Capable of storing -32767 -> 32767

Int Specifiers

  • short: 16 bits in size

    short int intThatIsAShort = 0;

  • long: 32 bits in size

    long intThatIsALong = 0;

  • long long: 64 bits in size

    long long reallyBigInteger = 0;


  • One byte in memory. (8 bits).

  • Holds a character but can also hold a number

    char thisCanHoldALetter = 'x'; char thisCanHoldANumber = 72;

Note about the ascii table

  • ASCII is just a number corresponding with a letter.

  • Look here for more information.


  • Holds floating point numbers

    float thisIsAFloat = 72.2;


  • Like a float but bigger.

    double thisIsADouble = 0;


  • Arrays are collections of multiple things

  • Have to be a set size.

  • Use braces to initalize

  • If you initalize one you initalize all.

    int arrayOfNums[100] = {0};


  • "Strings" are made up of mutliple chars. (Yes it does make sense! :))

    char arrayOfChars[81] = {0};

  • Null termination is added to the end.


Bare Metal Programming on the Raspberry Pi (Part 3) - Gabriel Evenfire | 2014-12-22

This is the third episode in a series on bare metal programming on the Raspberry Pi. This episode rounds out my initial stab at doing a series on RPI embedded programming based on my summer vacation project. This episode discusses how to write code with an eye towards using it in an embedded environment. It continues with a discussion of how coprocessors fit into the ARM architecture. It also describes how to manage coprocessors programatically in a very hackerish way using self-modifying code. Finally, the episode describes how to enable the virtual memory subsystem in the ARM as well as the cache. It includes some performance measurements of my code both with and without the cache enabled.

Here is some of the source material that I reference in this episode. See the previous episode show notes for information on how to get your own bare metal Raspberry Pi setup up and running.


  • Homepage:
  • Git repo: git://
  • My own repository of code that I wrote during this little project.

Hacker's Delight by Henry S. Warren Jr.

  • A fantastic book on low level computer mathematics. I find it a joy to read. I cannot recommend it highly enough. It belongs on anyone's shelf next to Knuth and other "programming bibles".



dwelch67's bare metal repository

Bare Metal Programming on the Raspberry Pi (Part 2) - Gabriel Evenfire | 2014-10-31

The second episode in a series on bare metal programming on the Raspberry Pi. This episode builds on part 1 by showing how interrupts work on the RPIs ARM chip and the framework I created to manage them. It then goes on to describe how an interrupt-enabled serial driver works. From there, the episode shows how we can use the serial cable in conjunction with a loader program to enable us to load bare-metal programs onto the RPI without having to copy them to the SD card each time. In the process, the episode describes the XMODEM protocol that the loader users for the file transfer process.

Here is some of the source material that I used while working on this little learning experience.


Bare Metal Programming on the Raspberry Pi (Part 1) - Gabriel Evenfire | 2014-10-16

This show is about programming on a Raspberry Pi with on operating system or libraries. In this programming environment, the only software that the CPU executes is the software that you write. This episode introduces how to configure the build environment and get a basic application up and running. From here one can leverage these techniques to build more sophisticated applications and deepen ones knowledge of systems programming.

Here is some of the source material that I used while working on this little learning experience.

dwelch67's bare metal repository


  • Homepage:
  • Git repo: git://
  • My own repository of code that I wrote during this little project.

Adafruit USB to TTL cable

Script to build the ARM toolchain



RPI Schematics

RPI Peripherals

Why C++? - garjola | 2014-09-10

In this episode, Garjola presents the C++ programming language by introducing its main features for object orientation, generic programming and functional style.

AWK - laindir | 2014-05-05

First of all, a correction. In the podcast, I mistakenly refer to one of the coauthors of the language as Kevin Weinberger. My humblest apologies to Mr. Weinberger, whose actual first name is Peter. I also neglected to mention one of AWK's most interesting features: its automatic field splitting. I hope to submit a followup podcast soon in order to rectify these two glaring mistakes.

AWK is a loosely typed interpreted programming language. Many useful functions in a UNIX programming environment, such as reading files, looping over input, matching regular expressions, and splitting strings into fields have been abstracted and are presented to the programmer as native parts of the language. This makes AWK ideal for text processing.

The basic structure of an AWK program is a list of rules. Each rule is made up of an optional pattern and an optional action. If the pattern is matched, the corresponding action is run. When AWK starts up, it loads the supplied program text, runs any rules with the special BEGIN pattern, then in turn, opens each file supplied on the command line (or stdin if no files or a - are specified). Each file is split into records based on the value in the RS (record separator) variable. AWK then loops through each record, splits it into fields based on the value in the FS (field separator) variable, and loops through each rule in the program. An empty pattern matches all records, so actions with no pattern run for every record. An empty action causes the current record to be printed.

The operator most unique to AWK is the $ (field access) operator. When followed by an integer literal or variable holding an integer value, it returns the corresponding field in the current record (counting from 1 up to NF, the number of fields special variable). $0 returns the entire record. If the supplied integer is greater than NF, it is treated as an uninitialized variable, which, in AWK, is treated dually as either the empty string, or the number 0, depending on the context in which it is referenced.

The most common type of pattern used in AWK (excepting, perhaps, the empty pattern) is a regular expression literal. It consists of a regular expression enclosed in forward slashes. This syntax is inherited from ed, the standard text editor, and has been passed down all the way to javascript. In AWK, a regular expression literal, alone as a pattern, is shorthand for $0 ~ /regex/, where ~ is the regular expression match operator (the string $0, current record, matches the supplied regular expression).

Programming languages 3 - C - garjola | 2013-09-06

Hi, my name is Garjola and you are listening to a contribution to
HPR. This is episode 3 of my programming language series and is entitled
"Getting started with the C programming language"

I am not going to teach you C, but just whet your appetite.

1 Intro

  • What C is useful for
    • Systems programming
    • Number crunching
    • Graphics
    • Embedded systems
      • Arduino
  • Advantages
    • speed
    • fine grained control of the memory management
    • close to the metal
    • the portable assembly language
  • Drawbacks
    • fine grained control of the memory management
    • close to the metal
    • the portable assembly language

2 History of the language

  • developed by Ken Thompson and Dennis Ritchie between 1969 and 1973
    at AT&T Bell Labs.
  • The origin of C is closely tied to the development of the Unix
    operating system, originally implemented in assembly language on a
    PDP-7 by Ritchie and Thompson, incorporating several ideas from
    colleagues. Eventually they decided to port the operating system to
    a PDP-11. B's inability to take advantage of some of the PDP-11's
    features, notably byte addressability, led to the development of an
    early version of C.

3 Uses

  C is often used for "system programming", including implementing
  operating systems and embedded system applications, due to a
  combination of desirable characteristics such as code portability and
  efficiency, ability to access specific hardware addresses, ability to
  pun types to match externally imposed data access requirements, and
  low run-time demand on system resources. C can also be used for
  website programming using CGI as a "gateway" for information between
  the Web application, the server, and the browser. Some reasons for
  choosing C over interpreted languages are its speed, stability, and
  near-universal availability.

  One consequence of C's wide availability and efficiency is that
  compilers, libraries, and interpreters of other programming languages
  are often implemented in C. The primary implementations of Python
  (CPython), Perl 5, and PHP are all written in C.

  Due to its thin layer of abstraction and low overhead, C allows
  efficient implementations of algorithms and data structures, which is
  useful for programs that perform a lot of computations.

  C is sometimes used as an intermediate language by implementations of
  other languages. This approach may be used for portability or
  convenience; by using C as an intermediate language, it is not
  necessary to develop machine-specific code generators.

  C has also been widely used to implement end-user applications, but
  much of that development has shifted to newer languages.

4 Characteristics of the language

  • imperative, compiled, static, weakly typed
  • structured programming
    • Uses functions but it is not functional, but rather procedural
    • control flow if/else, for, while
    • curly braces, semi-colons
  • all parameters are passed by value and references are simulated
    using pointers
  • A program is a function called main

5 Tooling and environment

  • editor
  • compiler
    • makefiles for convenience, although higher level tools such as
      autoconf/automake or cmake exist
  • debugger
  • IDEs
  • gnu tools for everything
    • emacs, pico, gedit, vi
    • gcc, clang
    • gnumake
    • gdb, xgdb, ddd
    • kdevelop

6 Hello World

  #include <stdio.h>

  int main(void) { printf("hello, world\n"); return 0; }

7 How to make a C program

  • Write your main function into a file called myprogram.c
  • compile your program
    • gcc -o myprogram myprogram.c
  • if you use other libraries than C's standard library, you will need
    to use a linker, like ld

  Examples taken from An Introduction to GCC
  by Brian J. Gough, foreword by Richard M. Stallman

  The classic example program for the C language is Hello World. Here is
  the source code for our version of the program:

  #include <stdio.h>

  int main (void) { printf ("Hello, world!\n"); return 0; }

  We will assume that the source code is stored in a file called
  ‘hello.c’. To compile the file ‘hello.c’ with gcc, use the following

  $ gcc -Wall hello.c -o hello

  To run the program, type the path name of the executable like this:

  $ ./hello
  Hello, world!

8 Pointers!

  C supports the use of pointers, a type of reference that records the
  address or location of an object or function in memory. Pointers can
  be dereferenced to access data stored at the address pointed to, or to
  invoke a pointed-to function. Pointers can be manipulated using
  assignment or pointer arithmetic.  The run-time representation of a
  pointer value is typically a raw memory address (perhaps augmented by
  an offset-within-word field), but since a pointer's type includes the
  type of the thing pointed to, expressions including pointers can be
  type-checked at compile time.

9 The standard library

  • just use man!
  On Unix-like systems, the authoritative documentation of the actually
  implemented API is provided in form of man pages. On most systems, man
  pages on standard library functions are in section 3; section 7 may
  contain some more generic pages on underlying concepts (e.g. man 7
  math_error in Linux).

  apropos sqrt |grep \(3\) man 3 sqrt

  man 3 qsort history

  • the not-so-standard libraries
    • gsl
    • gtk
    • X

10 Languages of the C family

  • C++, ObjectiveC, Java, C#, Go

11 Resources

  • [] : Learning GNU C by Ciaran

Programming languages 2 - Python - garjola | 2012-12-12

Programming languages 2 - Getting started with Python

Python is a very interesting language in the sense that it covers a very wide range of use cases.
  1. It can be useful for simple scripting tasks, that is automating repetitive tasks that you usually do by hand.
  2. It can also be useful for text file processing, like parsing log files or specific formats like XML.
  3. You can use use it as a glue language, that is a mix of system calls to command-line programs, like in scripting, but also by calling foreing language libraries which provide Python bindings.
  4. You can use Python as a first language in a Computer Science curriculum, since it is simple to learn and supports different programming paradigms (Object Oriented, Procedural, Functional).
  5. You can it also as an extension language, since a Python interpreter can be embedded in C/C++ programs.
  6. Python being a very rich language with a very rich standard library, you can use it to build very complex applications. There are many ways of using it to build complex Graphical User Interfaces, since many graphical libraries provide Python bindings (, GTK, etc.). Python also provides a default library for GUIs, which is called Tkinter and is based on Tcl/Tk.
  7. You can also use Python for web development, either by using the standard library utilities or by using one of the very popular web frameworks like Zope, Plone or Django.
  8. Finally, Python is also extensively used in scientific computing, since projects like SciPy, Numpy or Matplotlib provide a set of tools which allow Python to be as powerful as languages like Matlab or IDL with the advantage of being a full fledged language with a very rich standard library.

2 Installation

There are 2 current versions of Python: version 2 and version 3. Version 3 is not fully compatible with version 2, so if you are starting with Python, I think is is wise to go with version 3, but be aware that most existing applications and Open Source projects use version 2.

If you are using a GNU based system, chances are that Python is already installed in you system. Otherwise, it will be available in your distribution repositories. As far as I know, Python is also available on the Mac via the terminal. On widows, you will have to download a Python distribution from On this page you will also find links for downloading Python for Linux, MacOS, etc.

If you go to this site, you will notice that they mention alternative implementations of Python. The implementation I will be talking about here is the one done in C.

To install Python, you also can download the source code and compile it yourself.

3 Syntax and semantics

Have a look at this link

Python is intended to be a highly readable language. It is designed to have an uncluttered visual layout, frequently using English keywords where other languages use punctuation. Python requires less boilerplate than traditional manifestly typed structured languages such as C or Pascal, and has a smaller number of syntactic exceptions and special cases than either of these.

The simplicity of Python is demonstrated by its version of the classic "Hello world" program:

print("Hello world")


Python uses whitespace indentation, rather than curly braces or keywords, to delimit blocks; a feature also termed the off-side rule. An increase in indentation comes after certain statements; a decrease in indentation signifies the end of the current block.

Statements and control flow

Python's statements include (among others):

The if statement, which conditionally executes a block of code, along with else and elif (a contraction of else-if).

The for statement, which iterates over an iterable object, capturing each element to a local variable for use by the attached block.

The while statement, which executes a block of code as long as its condition is true.

The class statement, which executes a block of code and attaches its local namespace to a class, for use in object-oriented programming.

The def statement, which defines a function or method.

The import statement, which is used to import modules whose functions or variables can be used in the current program.

Each statement has its own semantics: for example, the def statement does not execute its block immediately, unlike most other statements.


Python expressions are similar to languages such as C and Java.

In Python, == compares by value, in contrast to Java, where it compares by reference. (Value comparisons in Java use the equals() method.) Python's is operator may be used to compare object identities (comparison by reference). Comparisons may be chained, for example a <= b <= c.

Python uses the words and, or, not for its boolean operators rather than the symbolic &&, ||, ! used in Java and C.

Conditional expressions in Python are written as x if c else y (different in order of operands from the ?: operator common to many other languages).


Methods on objects are functions attached to the object's class; the syntax instance.method(argument) is, for normal methods and functions, syntactic sugar for Class.method(instance, argument). Python methods have an explicit self parameter to access instance data, in contrast to the implicit self in some other object-oriented programming languages (for example, Java, C++ or Ruby).


Python uses duck typing and has typed objects but untyped variable names. Type constraints are not checked at compile time; rather, operations on an object may fail, signifying that the given object is not of a suitable type. Despite being dynamically typed, Python is strongly typed, forbidding operations that are not well-defined (for example, adding a number to a string) rather than silently attempting to make sense of them.

Python allows programmers to define their own types using classes, which are most often used for object-oriented programming. New instances of classes are constructed by calling the class (for example, SpamClass() or EggsClass()), and the classes themselves are instances of the metaclass type (itself an instance of itself), allowing metaprogramming and reflection.

4 Interpreter

The section 3 of the python tutorial (An informal introduction to Python) gives a very good overview of the use of the interactive interpreter.

Of course, if you are going to write long programs, you will want to save them to files which can then be passed to the interpreter for execution.

5 Standard library

Python has a very rich standard library, that is a set of modules which are part of the standard Python installation and which provide many interesting functions which in many other languages are only provided by 3rd party libraries :

  • Operating System Interface
  • Command Line Arguments
  • Error Output Redirection and Program Termination
  • String Pattern Matching
  • Mathematics
  • Internet Access
  • Dates and Times
  • Data Compression
  • Performance Measurement
  • Output Formatting
  • Working with Binary Data Record Layouts
  • Multi-threading
  • Logging
  • Decimal Floating Point Arithmetic

6 Documentation and tutorials

The main reference is the Python documentation page at . There you will find a very useful tutorial (this is the place to start), the standard library reference, and many other interesting information.

Programming languages 1 - Introduction - garjola | 2012-02-27

This is the first episode on a series about computer programming languages. In this episode, I will start by discussing why you may want to learn a programming language, then I will give an introduction about what programming languages are, which are the different types of programming languages, their history, and I will also give some pointers to resources which can be useful to get you started with programming.

Eric Raymond's "How to become a hacker" essay, available at

1 Wikipedia sources:

2 Resources for learning to program

2.1 Easy

2.1.1 List of resources on Wikipedia

2.1.2 The Python tutorial

2.2 Intermediate

2.2.1 Structure and interpretation of computer programs

Programming 101 Part 4 - Xoke | 2009-05-20

Xoke continues his programming series

Python Programming Part 3 - Xoke | 2009-02-25

for x in range(1, 10):

for x in range(1, 11):

y = 0
for x in range(1,101):
       y = y + x

y = 0
x = 1
while x < 101:
       y = y + x
       x = x + 1
print (y)

x = 0
y = 0
z = 1

while z < 100:
       x = y
       y = z
       z = x + y
       print (z)

x = 0
y = 0
z = 1

while z < 100:
       print (z)
       x = y
       y = z
       z = x + y

x = 0
y = 0
z = input('What number do we start from?')
i = input('And up to which number should we calculate')

while z < i:
       print (z)
       x = y
       y = z
       z = x + y

Illustrious Programmer E1: Vocab and Basics - jelkimantis | 2009-02-16

Jelkimatis continues his Illustrious Programmer series

Illustrious Programmer Ep 0 - jelkimantis | 2009-02-12

first ep in Jelkimantis' new series

Python Programming 101: Part 2 - Xoke | 2009-01-28

print ("Hello World")

print ("Hello \"World")

x = 1
print (x)

x = 1
x = x + 5
x = x * 7
print (x)

x = 1 + 5 * 7
print (x)

x = (1 + 5) * 7
print (x)

# This is a comment
x = (1 + 5) * 7
# print ("5")
print (x)

x = "Hello World"
print (x)

x = "Hello"
y = "World"
print (x+y)

x = "Hello"
y = "World"
print (x + " " + y)

sFirstName = "John"
sSurname = "Smith"
print ("Dear " + sFirstName + " " + sSurname)

x = 13
sFirstName = "John"
sSurname = "Smith"
if x < 12:
	print ("Good Morning " + sFirstName + " " + sSurname)
	print ("Good Evening " + sFirstName + " " + sSurname)

x = 11
sFirstName = "John"
sSurname = "Smith"
if x < 12:
	print ("Good Morning " + sFirstName + " " + sSurname)
	print ("Good Evening " + sFirstName + " " + sSurname)
print ("When does this get printed?")

Programming 101: The Basics - Xoke | 2008-12-31

Xoke starts the Programming series giving some background on his experience as well as some programming fundamentals.