Home
 
Welcome to GordonTillman.Info
Django UUIDField
Written by Gordon Tillman   
Friday, 12 December 2008 19:52

There are several Django uuid field implementations floating around. My favorite one is part of the django_extensions project. It stores uuid's as a 36-character string. But newer PostgreSQL implementations have native support for a uuid column type. Here is a UUIDField implementation (based on the work done by the django_extensions project) that uses a uuid column type in PostgreSQL and char(36) column types in other databases. I have tested dumping and loading data between different databases and it works fine.

Note: I've detected a problem with using inherited models so do not use this as is until I can post a resolution.

Last Updated on Tuesday, 16 December 2008 21:51
Read more...
 
Extracting the date/time portion of a version-1 UUID
Written by Gordon Tillman   
Tuesday, 09 December 2008 15:01

RFC 4122 describes the formats of the various types of Universally Unique Identifiers, or UUIDs. A Version 1 UUID contains a time stamp “represented by Coordinated Universal Time (UTC) as a count of 100-nanosecond intervals since 00:00:00.00, 15 October 1582 (the date of Gregorian reform to the Christian calendar).” This article describes how to get a datetime.datetime object that represents this timestamp.

Read more...
 
Unicode in Python Source Code
Written by Gordon Tillman   
Tuesday, 09 December 2008 14:34
If you want to save your Python source code files using UTF-8 encoding, just put the following at the top of your source code files. The #!... line is optional.
#!/usr/bin/env python
# -*- coding: UTF-8 -*-

Note: In Python 3.0 the default source encoding is UTF-8. See PEP 3120 for more information.

Last Updated on Tuesday, 09 December 2008 16:30
 
Division in Python
Written by Gordon Tillman   
Tuesday, 09 December 2008 14:55

The normal behavior in Python when dividing two Integers is to give an Integer result. This is true at least up through Python version 2.5. In the future this will change so that division will yield a floating point number. If you want that future behavior now, just include this line in you Python program file:

Last Updated on Tuesday, 09 December 2008 14:59
Read more...
 
Introduction to geopy
Written by Gordon Tillman   
Monday, 08 December 2008 22:51

geopy is a really cool Python module that is hosted on Google code. Makes it dead easy to do geocoding from your Python program.

Last Updated on Monday, 08 December 2008 23:17
Read more...
 
«StartPrev1234567NextEnd»

Page 2 of 7