Q:

Iterating over Python objects

I am attempting to write a program that calculates a certain formula based on zipcode, lat, and lng. 
My initial idea was to create an object for each zip code.
class destination():
def __init__(self, zipcode, count):
    self.zipcode = zipcode
    self.count = count

def getCount(self):
    return self.count

def getZip(self):
    return self.zipcode

def getLatitude(self):
    return self.lat 

def getLongitude(self):
    return self.lng 

def __str__(self):
    return "%s at %s , %s" % (self.zipcode, self.lat, self.lng)

def getCoords(self):
    '''
    Must be called before getLatitude or get Longitude
    '''
    self.place, (self.lat, self.lng) = gn.geocode(str(self.zipcode))  
    self.city = self.place.split(",",1)
    self.name =  self.city[0]
    self.value = str(count)+","+self.name

    return self.value

That works fine as I can successfully iterate over a list and create the object and extract the necessary information out of i
zipList = ['54971','46383','90210']

for i in zipList:
    i = destination(i,count)
        count += 1

Will return
1,Ripon
-88.8359447
43.8422049
2,Valparaiso
-87.0611412
41.4730948
3,Beverly Hills
-118.4003563
34.0736204

What I cant seem to wrap my head around is how to set up the program so that it iterates through the list calling the haversine function with the correct information for each item.  
def haversine(latStart,lonStart,latEnd,lonEnd):

Example:
if my list is 
zipList = ['54971','46383','90210']

Then it will do the calculation for 54971 to 46383, 54971 to 90210, and 46383 to 90210

A:

Try using itertools, the combinations function may be what you want.

A:

Ask for all pairs of zipcodes from the list, and use them:
import itertools

for start, stop in itertools.combinations(zipList, 2):
    print start, stop
    # now pass start, stop to your function

