File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -37,12 +37,12 @@ Download the tarball, untar and run `python setup.py install`
3737 The following returns the information as a python object
3838 """
3939 pylocinfo = pyloc.info
40- pylocinfo.ip => '8.8.8.8'
41- pylocinfo.city => 'Mountain View, CA'
42- pylocinfo.country_name => 'UNITED STATES'
43- pylocinfo.country_code => 'US'
44- pylocinfo.latitude => ' 37.402'
45- pylocinfo.longitude => ' -122.078'
40+ print pylocinfo.ip # '8.8.8.8'
41+ print pylocinfo.city # 'Mountain View, CA'
42+ print pylocinfo.country_name # 'UNITED STATES'
43+ print pylocinfo.country_code # 'US'
44+ print pylocinfo.latitude # 37.402
45+ print pylocinfo.longitude # -122.078
4646
4747
4848 """
Original file line number Diff line number Diff line change @@ -53,8 +53,14 @@ def __init__(self, properties):
5353 self .city = properties ['city' ]
5454 self .country_name = properties ['country_name' ]
5555 self .country_code = properties ['country_code' ]
56- self .latitude = properties .get ('lat' , None )
57- self .longitude = properties .get ('lng' , None )
56+ self .latitude = None
57+ self .longitude = None
58+ latitude = properties .get ('lat' , None )
59+ if latitude :
60+ self .latitude = float (latitude )
61+ longitude = properties .get ('lng' , None )
62+ if latitude :
63+ self .longitude = float (longitude )
5864
5965class PyLocation (object ):
6066 """The :class `PyLocation` object. Used to perform the various operations
You can’t perform that action at this time.
0 commit comments