You have to think in terms of the python objects.

geoNames API gives you a dictionary with one key: postalcodes
The value of the postalcodes entry in the dictionary is a list of 
dictionaries, each with the info of one postal code.

If the list is empty the previous code 

for x in location_data['postalcodes']:

should work since there would be nothing to iterate over (you never get a 
value for x and the 'for' never loops).

Denes


On Monday, October 5, 2015 at 12:27:41 AM UTC-4, Alex Glaros wrote:
>
> am having hard time finding syntax for checking for empty API data in 
> above example
>
> Here is what geoNames.org APII returns when nothing is found:
>
> {"postalcodes":[]}
>
>
> tried many variations of:
>
> {{if location_data:}}
>
> If I include "postalcodes" I receive "Key" error. Any ideas? 
>
> thanks,
>
> Alex
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to