Browse files

Convert longitude and latitude to floats, update the readme

  • Loading branch information...
1 parent 8dbc62c commit 8e88a835688a3fd84d16fcaf6ee4b22600e974cd Mark Costello committed Jul 5, 2012
Showing with 14 additions and 8 deletions.
  1. +6 −6 README.md
  2. +8 −2 pylocation/core.py
View
12 README.md
@@ -37,12 +37,12 @@ Download the tarball, untar and run `python setup.py install`
The following returns the information as a python object
"""
pylocinfo = pyloc.info
- pylocinfo.ip => '8.8.8.8'
- pylocinfo.city => 'Mountain View, CA'
- pylocinfo.country_name => 'UNITED STATES'
- pylocinfo.country_code => 'US'
- pylocinfo.latitude => '37.402'
- pylocinfo.longitude => '-122.078'
+ print pylocinfo.ip # '8.8.8.8'
+ print pylocinfo.city # 'Mountain View, CA'
+ print pylocinfo.country_name # 'UNITED STATES'
+ print pylocinfo.country_code # 'US'
+ print pylocinfo.latitude # 37.402
+ print pylocinfo.longitude # -122.078
"""
View
10 pylocation/core.py
@@ -53,8 +53,14 @@ def __init__(self, properties):
self.city = properties['city']
self.country_name = properties['country_name']
self.country_code = properties['country_code']
- self.latitude = properties.get('lat', None)
- self.longitude = properties.get('lng', None)
+ self.latitude = None
+ self.longitude = None
+ latitude = properties.get('lat', None)
+ if latitude:
+ self.latitude = float(latitude)
+ longitude = properties.get('lng', None)
+ if latitude:
+ self.longitude = float(longitude)
class PyLocation(object):
"""The :class `PyLocation` object. Used to perform the various operations

0 comments on commit 8e88a83

Please sign in to comment.