Re: Geohashing

2009-04-30 Thread norseman
Marco Mariani wrote: norseman wrote: The posting needs (its creation) ... DATE. ... The code needs to state OS and program and version used to write it. And from there - user beware." Which would reduce the confusion greatly. I got the same error message and decided it was from an incomp

Re: Geohashing

2009-04-30 Thread Marco Mariani
norseman wrote: The posting needs (its creation) ... DATE. ... The code needs to state OS and program and version used to write it. And from there - user beware." Which would reduce the confusion greatly. I got the same error message and decided it was from an incompatible version, using

Re: Geohashing

2009-04-29 Thread norseman
Marco Mariani wrote: djc wrote: Python 2.5.2 (r252:60911, Oct 5 2008, 19:29:17) geohash(37.421542, -122.085589, b'2005-05-26-10458.68') ^ SyntaxError: invalid syntax The byte type is new in 2.6 -- http://mail.py

Re: Geohashing

2009-04-29 Thread Marco Mariani
djc wrote: Python 2.5.2 (r252:60911, Oct 5 2008, 19:29:17) geohash(37.421542, -122.085589, b'2005-05-26-10458.68') ^ SyntaxError: invalid syntax The byte type is new in 2.6 -- http://mail.python.org/mailman/listi

Re: Geohashing

2009-04-29 Thread djc
Raymond Hettinger wrote: > import hashlib > > def geohash(latitude, longitude, datedow): > '''Compute geohash() in http://xkcd.com/426/ > > >>> geohash(37.421542, -122.085589, b'2005-05-26-10458.68') > 37.857713 -122.544543 > > ''' > h = hashlib.md5(datedow).hexdigest() >

Re: Geohashing

2009-04-28 Thread Paul Rubin
Raymond Hettinger writes: > p, q = [('%f' % float.fromhex('0.' + x)) for x in (h[:16], ... Cool, I didn't know about 'fromhex'. -- http://mail.python.org/mailman/listinfo/python-list

Geohashing

2009-04-28 Thread Raymond Hettinger
import hashlib def geohash(latitude, longitude, datedow): '''Compute geohash() in http://xkcd.com/426/ >>> geohash(37.421542, -122.085589, b'2005-05-26-10458.68') 37.857713 -122.544543 ''' h = hashlib.md5(datedow).hexdigest() p, q = [('%f' % float.fromhex('0.' + x)) for x