Posts

Showing posts from February, 2005

Python: Unicode

Python has very good support for unicode, but half the time it's gets in the way. Java, by default, uses the Latin1 encoding (aka ISO-8859-1) which makes programming in languages like Portuguese very easy. Python's default, unfortunately, is 7 bit ASCII. If you use any accents you have to properly decode it for it to work without an error. A quick work around is to create a file called sitecustomize.py in your python lib directory and put in the following: import sys sys.setdefaultencoding('latin1') This definitely makes coding with European accents a lot easier. Here's a good article on unicode and python. I've read that some people have had problems with sitecustomize and third party modules, but I believe that's only if you set it to utf8. The other thing you need to do is put: # -*- coding: latin1 -*- near the top of your python program. Neil Hodgson recomends testing your libraries with the -U switch for Python and by trying sys.setdefaultenco

Tools: Matplotlib for Python

Image
When it comes to doing graphs, Matplotlib is the one to use. It's an open source library that does a wonderful job of creating graphs. As you can see above it also does a good job with anti-aliasing the lines (this is zoomed in from a black and white graph I did for my wife). The site has a lot more samples which show the features of the library. I was able to create a figure with six graphs in about 10 minutes, without ever having used the library before (just copied from the examples). To get all the little text elements and adjustments took a bit longer, but it is still impressive how quickly you can get going. In a few lines you can output the graph to the screen using either Tkinker, wxPython, or GTK and have it interactive as well (zoomin, etc.). You can also output to PNG, JPG, SVG, PS and other output formats. The anti-aliasing is done so well because Matplotlib uses the Anti-Grain Geometry library which can do sub-pixel anti-aliasing of lines ( check it out ). Mat

UI: iRiver

I've finally seen the iPod. The UI is very nice on the iPod, the thumb wheel is brilliant. The buttons on my iRiver H340 are quaint, in retrospect. I wish that iRiver put PageUp, PageDown buttons on their interface, when scrolling through hundreds of directories the +/- buttons are too slow. The Dot and A-B buttons on the right could be overloaded to be PageUp and PageDown, since they aren't used in that mode. Another complaint I have is that when you press the dot button goes between the different playing modes which have names like "D", "A", "SFL DA". Why don't the put near the bottom a long description of the playing mode, for a second or two? So that SFL DA becomes, "Shuffle, Directory All". Which brings me to another complaint, I don't see any difference between "SFL DA", and "SFL D". I was hoping that one would shuffle between all the files in the current directory and below , yeash.

Tools: Frink calculator

I highly recommend using Frink instead of, say, windows Calc. It's a free, but not open source, Java program. It's command line driven but very powerful. I especially like the built in conversion capabilities and translation features. Here's the feature list: Tracks units of measure (feet, meters, tons, dollars, watts, etc.) through all calculations and allows you to add, subtract, multiply, and divide them effortlessly, and makes sure the answer comes out correct, even if you mix units like gallons and liters. Arbitrary-precision math , including huge integers and floating-point numbers, rational numbers (that is, fractions like 1/3 are kept without loss of precision,) and complex numbers. Advanced mathematical functions including trigonometric functions (even for complex numbers,) factoring and primality testing , and base conversions . Unit Conversion between thousands of unit types with a huge built-in data file . Date/time math (add off