python 2.6 code from Allan