Learning Python

If you'd like to learn Python, you might find this page useful: Python for Beginners, as well as the Python-tutor mailing list. I'm now a list admin, so I can be perfectly objective when I say that Tutor rocks. (I am no longer a list administrator.) If you're on this page, you're probably looking for my One Day of IDLE Toying web guide.

Python Stuff

Here are a few things I'm doing with Python:

IDLE Introduction --- One Day of IDLE Toying

For newcomers to the Python language, I have a small tutorial that shows how to use the IDLE environment. It's intended for people who are still quite new to this programming thing that everyone keeps mumbling about.


This is one of the simplest modules one can write: there's no code! *grin* This provides a new module called __std__ that provides controlled access to the Standard Library.


Scheme in Python! I've written some code that implements a Scheme interpreter in Python. The code tries to model the metacircular evaluator from The Structure and Interpretation of Computer Programs. For those who are taking CS61A: hello!

truly_random --- Truly random number generator

Fourmilab provides a service called Hotbits that uses radioactive decay as a source of random bits. truly_random is a module that exposes Hotbits as a Python module, and should be as easy to use as Python's standard random module. truly_random can also use /dev/random.


An implementation of the Aho-Corasick keyword automaton. Actually, I didn't do much work at all; the core of the implementation is taken from the FFPF project.


A ``Suffix Tree'' is a powerful data structure that exposes the structure of a string in a very beautiful way. SuffixTree is a package that allows Python programmers to play with this structure.


The popular game, in Python!


A pure Python implementation of a scanf-like function for formatted input.


I've been reading up on propositional logic, and with some experience from fiddling with Pythonica, I thought it might be neat to write a similar framework for propositions. This code nowhere near done yet, but I might as well link it while I still remember about it.

Pythonica fixing

I'm playing around with Pythonica to see if I can fix some bugs.

A Quick Introduction to Python

I had written up a small introduction to Python a while back, but had forgotten to post it up on the Web. It's a bit dated, but it might be useful for others. Here is is: introduction.ps (with LaTeX source introduction.tex).

Lovins Stemmer

This lovins module is a C extension wrapper module that applies the Lovins stem algorithm, a tool used in natural language processing. It's another fun way to mess with words.

Useless Python

I've contributed a few scripts to Useless Python, which is a site that collects snippets of dubious applicability. Come contribute to the madness. *grin*

Gtk+ Selections

I've been playing around with the pygtk module by James Henstridge. Here's a small script that plays around with the primary clipboard. Selection.py. Parts of it are based on Alan Cox's googlizer script. With it, you should be able to get and set the selection buffer.

CGI Cookies

Here's a small example that shows how to use cookies in Python: cookiecounter.py.

Secret Decoder Ring in Python

This is a small example of how NOT to use the curses library. *grin* It's a small secret decoder ring program, and it has horrible programming structure. I had fun writing it. circularwriting.py.

A* Search

Here's an implementation of the A* search algorithm: a_star_search_2.py. It requires a priority queue: priorityqueue.py. One sample use of A* is in the finding of solutions to the eight puzzle: eight_puzzle.py.

Update: (2004/10/15) I regret to report that I have been forced to drop the eight_puzzle.py code off my site; I've gotten reports that some cheaters have been turning in my code as their own homework. Please do not do that.


PyHeap-0.1.tar.gz. Here's an C extension module for a priority queue using a binary heap. I've tried to comment it extensively, since I'm probably going to forget how it works in a few days. *grin*. But it's another example of how one can write a module in C and have it nicely packaged in Python.


PyTopological-0.2.tar.gz Another C Extension module that provides a nice topological sorting routine. This is a relatively simple example that, in all practicality, should have been written in straight Python. However, to get familiarity with the Python/C API, I wrote it in gruesome C instead.


pybitmap-0.1.tar.gz This is an example of a Python C extension class which provides a simple PyBitmap class that has a nice list-like interface. It should help people who want to see a practical example of an extension. (To tell the truth, I just wanted the Sieve of Eratosthenes to work really darn fast.)


mmixviewer.py A small program I'm writing to study output from a cool assembly language called MMIX. MMIX is designed by Donald Knuth, and is very interesting. (What other assembly language includes SYNC and SWYM as opcodes?) mmixviewer.py does a lot of string and list manipulation, as well as some getopt stuff. At the same time, the code itself is a little rough, so there's plenty of room for improvement.


I've written a small wrapper around Raph Levien's libhnj hyphenation library. Yes, it's a Knuth thing. *grin*

Email any questions to dyoo@hkn.eecs.berkeley.edu. Thank you!

Back to main.