I returned to Python in Oct 2010.

I have two problems to solve,

  1. converting my bliki to wordpress
  2. scripting for KDB & Hadoop

Notes on the old Bliki

  1., a list of notes
  2., an article about my initial python build on the Cobalt Qube. This is really no longer relevant, and an example of content, that should NOT be brough across.

Notes on File I/O


Notes on Date and Time

Python does not load the datetime, calendar or time modules as default. They need to be imported.


I also found the following tutorial useful.

There is an example of how to use gmtime and strfdate in my wiki entry, on Snipsnap to WordPress.

Notes on

Originally posted on my sun/oracle blog in Feb 2009, copied here in July 2016.

We also discussed Python. I have been trying to write a game theory solver for a 2×2 formal game. I was representing the game as a dictionary so that I could retrieve game scores using the strategy names. One problem is that two dimensional dictionaries get syntactically cumbersome. I had ended up with a list as the key. In theory it should make the programming easier, where game is a dictionary attached to class instance g.

i.e. score =[(‘decoy’, ‘defend’)]

makes great sense where decoy and defend are blue and red strategies, however, I have usually placed the evaluation of a score in an iteration, and so coding the strategy names is rare e.g.

strategies=['heads', 'tails'];
for s in strategies:
    # some iterated code

It is probably simpler to represent the game as a 2×2 matrix held in a list and to use the classic technique of holding the names of the strategies in an ordered list so we can translate the matrix cell location such as n(1,1) into n(tails,tails) by looking co-ordinates up in one, or two name lists.

score=matrix(strategies.index('heads'), strategies.index('heads'))

This would also have the advantage that I could look for and use the matrix manipulation packages that exist to avoid writing a lot of code. The code would look a lot simpler, and not just because I have put a lot of it in an external package; this is usually a good clue that the answer is correct.

Lesson 1: Be careful when using dictionaries.

Python Path

Actually PYTHONPATH, according to my findings, the python module loader looks for modules in the same directory as the top level file, the PYTHONPATH, the standard library directories and then the contents of any .pth directories.  The last technique is useful for windows and where you want it towards the end of the search order.

Related Posts

  • Disqus This is page contains complex html i.e. javascript, the page must only be edited as […]
  • Python and datetime Links Here are some links, Official […]
  • Planet Planet I started using Planet in about 2008 2006, it would seem? I rapidly came too "Planet […]
  • Converting dates to strings using Python While working on converting ello.json to rss, I needed to convert the date formats, I […]
  • Unicode in Python It's a very long time since I have had to deal with binary code translations, but when […]

Leave a Reply

Your email address will not be published. Required fields are marked *