GeocoderDotUS... Syntax of Python check for 'None'
Question: 
    import csv
    from geopy import geocoders
    import time
    
    g = geocoders.GeocoderDotUS()
    
    spamReader = csv.reader(open('locations.csv', 'rb'), delimiter='\t', quotechar='|')
    
    f = open("output.txt",'w')
    
    for row in spamReader:
        a = ', '.join(row)
        #exactly_one = False
        time.sleep(1)
    
    
        place, (lat, lng) = g.geocode(a)
    
    
        if None in (lat, lng):
            f.write("none")
        else:
            b = str(place) + "," + "[" + str(lat) + "," + str(lng) + "]" + "\n"
            print b
            f.write(b)
    

So I have established that if GeocoderDotUS does not find an address it will
return None. I have written some script to attempt to check for None however I
still seem to be getting this trace back. I am a bit perplexed.

    
    
    Traceback (most recent call last):
    File "C:\Users\Penguin\workspace\geocode-nojansdatabase\src\GeocoderDotUS.py", line 17, in <module>
    place, (lat, lng) = g.geocode(a)
    TypeError: 'NoneType' object is not iterable
    

Is there some error in my check for None systax? Thanks in advance for any
help out....


Answer: As you can see in the error message, the problem is in the `place, (lat, lng)
= ...` line.

It is **the g.geocode calll** which returns **None** (and you try to assign
this to the `place` variable and the `lat, lng` tuple immediately, which
obviously must fail).

So try something along these lines:

    
    
    result = g.geocode(a)
    if result:
        place, (lat, lng) = result
    else:
        # ...
    

