09:30 Thu, 23 Sep 2010
You have no doubt been using python's print statement for yonks and are
pretty familiar with it. You know that you can use
the string formatting or interpolation operator. Most people use the
standard formatting types of %s, %d, and so on. I have recently changed
to using the less common dictionary mapping and here I go through the
benefits and why I changed.
% is the operator that allows you to do C style sprintf
operations. If you don't know them, they let you substitute values into
a string, like this:
print "%s is the time" % "now"
which give the result "now is the time". The '%s' is an indicator to
insert a string here, and the string to insert is in the second part of
the expression, the 'now'. There are many other types of formatted
insertions: int, float, scientific and so on as well as string.
If you do any sort of web programming, you use the
statement a lot. After all, the purpose of your program is to
generate HTML for the web server to serve up to your users, and you make
12:05 Wed, 07 Jul 2010
I've been spending the last couple of months teaching myself Python properly. I already
had some basic knowledge of it, enough to do, say, some tasks equivalent
to Bash shell scripting, but I knew I didn't know the language
properly. I thought I would jot down some of the references and texts I
If you know any programming language at all, you will find Python easy.
Its syntax is natural and clear. If you have formal programming skills,
and by that I mean that you can program in another language fairly
proficiently, you will find that Python has an elegance that delights;
it is a beautiful language. On top of that, it has object-oriented
features, data-oriented features, and some functional
programming features. As well, it has the rapid development
facility of any scripted language, and yet it is fast.
On to texts. I read a great deal and already have several hundred
books, so I now intentionally limit my book-spending budget. I found
that this wasn't a hinderance here, though. There are some excellent
08:25 Thu, 04 Feb 2010
Have you sometimes wanted to make a quick graph or a pie chart to
display on your website? Decided it was too hard for the amount of
effort and given up? There is a very simple solution that is remarkably
easy. You can use Google's Visualization API to create the graphs for you with just a
few lines of code.
Here is a screen shot of a very simple pie chart. Note the extra
features such as a slice that pops out to identify it, a pop up with
more information, and sorted columns in the table. These features come with it,
you don't need to do anything.
The image shows a pie chart and a table. You can show either or both
plus several other types of graphs. I think it looks professional and neat.
though on my site it is less than a second). Here is the actual
page from which the screen shot was taken. You will notice it is quite
10:44 Sun, 20 Dec 2009
I wanted a simple light-weight personal blogging tool that lets me write in flat files.
Like many others,
I very much dislike editing text in a browser, especially anything more than a
that their response time has crept up to several tenths of a second, very frustrating for a
touch-typist who needs response times of around a tenth to catch
errors 1. So, this tool needed to work with flat
files that I could edit in vim and easily transfer up to the blog host.
As well, it needed to be light-weight. I can't see my blog ever running to more
than a few hundred entries per year max. Tools like Wordpress et al are too heavy
for me, in the sense that their processing slows things down by comparison.
Python would be good, I prefer it to PHP. I really like it, it is a great language.
Also, I wanted some simple things like categories and comments, and search would
be nice too.
Originally, I had tried pyblosxom, but I found the lack of documentation