After some initial experiments with sqlite as a replacement for a json data file format (which I did not pursue in the end), I have now started using sqlite in earnest. And I must say that I quite like it.
Articles about programming
As an engineer I do a lot of calculations. These can be done with pen and paper and a calculator, in an IPython notebook or in a throwaway spreadsheet. All of these methods have shortcomings, though.
Pen and paper is hard to share and (in my case) hard for others to read. In IPython you can assign the results of calculations to a variable, but you have to perform a separate action to display them. And spreadsheets in general show you the results but not the calculations.
So I wrote a simple function in Python to help me with that. Using this function I can print both simple assignments and relatively complex calculations. And it shows both the calculation and the result.
With leading white space governing the indentation level and so the grouping of statements, Python code already looks relatively clean.
Yet there are additional tools that will help you improve your code.
Sometimes I miss the C’s plain old struct in Python.
Of course Python has dictionaries, but I prefer to write a.b over a['b'].
Here are several ways of doing something akin to a struct in Python.
According to my revision control systems (rcs in those days), I’ve been using gnuplot to make graphs since at least 2002. And I’ve got it set up via a custom gnuplotrc to match the style of the TeX documents I often use the graphs in.
At work we have an Instron 3369 machine for material testing. Recently, I wanted to visualize some tensile test data in ways that I couldn’t get into the test report.
If you would look over my github repositories, you’ll see that most of my programs are pretty small. And in general they are command-line applications. And that is good, because small is beautiful and simplicity is a virtue.
With Python it is relatively easy to make programs go faster by running things in parallel on multiple cores. This article shows you how.
We sill concentrate on a type of problem that is easy to parallelize.
Sometimes one has to convert numbers from and to different formats. Below are some examples in Python 3 that I picked up over time. What you see are excerpts of IPython sessions.
To and from hexadecimal (base 16):
In : hex(100) Out: '0x64' In : int(0xa7) Out ...