Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: Convert Latitude, Longitude To TimeZone

Thread Tools

Re: Convert Latitude, Longitude To TimeZone

Roy Smith
Posts: n/a
In article <(E-Mail Removed)>,
Steve B <(E-Mail Removed)> wrote:

> I found a piece of code
> [
> ] which uses the function []
> When I try to run the code, I get the error geonames is not defined (This is
> the function previously linked to)

The best thing to do when asking questions like this is to copy-paste
the exact error message you got. It was probably something like:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'geonames' is not defined

In this example, it's easy enough to figure out what went wrong from
your description, but in general, giving the exact error helps in the

> geonames_client = geonames.GeonamesClient('Username_alpha')
> geonames_result = geonames_client.find_timezone({'lat': 48.871236, 'lng':
> 2.77928})
> user.timezone = geonames_result['timezoneId']

You simply never imported the geonames module. Somewhere before your
first line of code, you want to add:

import geonames

This assumes that you've saved the module in a file named "".
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Code to convert MGRS coordinates to latitude and longitude (degrees,minutes, seconds) Java 1 08-13-2012 04:46 PM
TimeZone change - how to use TimeZone class axrock Java 8 03-25-2009 11:54 PM
TimeZone calculation on Windows Vista with DateTime::TimeZone Ami Perl Misc 5 09-24-2007 07:27 AM
Convert windows TimeZone to Java TimeZone asaf Java 3 09-11-2006 05:40 PM
Convert from HEX to decimal Latitude and Longitude Java 5 08-14-2006 01:20 PM