Question

All,

This may be a pretty novice question but I am stuck on how to do this in Python. What I need to do is, set the to and from params when requesting data from Panaramio.

http://www.panoramio.com/map/get_panoramas.php?set=public&from=0&to=100&minx=-180&miny=-90&maxx=180&maxy=90&size=medium&mapfilter=true

Panoramio only allows you to return 100 records at a time so I need to build out the url string to show the advancement of the sets of 100. eg. 101-200, 201-300, etc. Is there an example anywhere that will show me how to do this type of paging using Python?

Thanks, Adam

UPDATE: The following example seems to do what I want it to do. Now I have to figure out how to do the actual iteration from 101-200, 201-300, etc...From there I can take those values and build out my query string. Does this make sense?

def counter(low, high):
    current = low
    while current <= high:
        yield current
        current += 100

if __name__ == '__main__':

    for c in counter(100, 200):
        print c

UPDATE #2: I was making it harder than it should have been

def counter(low, high):
    while low <= high:
        yield low, high
        low += 100   
        high += 100  

for i in counter(1, 100):
        print i
Was it helpful?

Solution

for number in range(1, 301, 100):
    low = number
    high = low + 100
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top