Archive for the ‘Python’ Category

Absolute, Relative, and Splitting Paths in Bash

Tuesday, 1 December 2009

The main stumbling block with splitting paths in Bash is converting a relative path into an absolute one.

Searching the Internet I found many partial solutions, but none was entirely satisfactory. There may be a better solution out there, but I didn’t find it.



Friday, 20 November 2009

Running a simple script over a file containing a list of basic English words revealed the following palindromes.


Python Source Code Encodings

Saturday, 17 October 2009

If when you try to run a fragment of python like this:


### comment with a £pound sign
if __name__ == '__main__':

you get an error such as

SyntaxError: Non-ASCII character '\xa3' in file on line 3,
  but no encoding declared ...

then what you need is an encoding declaration on the first or second line of the file.


Painters and @Decorators?

Tuesday, 29 September 2009

Python Decorator Library


Type Enforcement

HCF without Division

Wednesday, 8 April 2009

The previous blog entry reminded me of this…


Division via Multiplication

Wednesday, 8 April 2009

In very special circumstances, integer division can be replaced by (integer) multiplication.