I am just starting with python and I am trying to write a program that interfaces with flickr. I am using the interface flickr.py found at the following link:


I am calling the following function:

myPhotos = myPhotoSets[0].getPhotos()

The shell is telling me there is an error in this function from flickr.py

def _doget(method, auth=False, **params):
    #uncomment to check you aren't killing the flickr server
    #print "***** do get %s" % method

    params = _prepare_params(params)
    url = '%s%s/?api_key=%s&method=%s&%s%s'% \
          (HOST, API, API_KEY, method, urlencode(params),
                  _get_auth_url_suffix(method, auth, params))

    #another useful debug print statement
    #print url
    return _get_data(minidom.parse(urlopen(url)))

def getPhotos(self):
        """Returns list of Photos."""
        method = 'flickr.photosets.getPhotos'
        data = _doget(method, photoset_id=self.id)
        photos = data.rsp.photoset.photo
        p = []
        for photo in photos:
            p.append(Photo(photo.id, title=photo.title, secret=photo.secret, \
        return p

Here is the error:

Traceback (most recent call last):
  File "C:\Users\Mike\Desktop\My Dropbox\School\CPSC315\Assignment4\main.py", line 8, in <module>
    myPhotos = myPhotoSets[0].getPhotos()
  File "C:\Users\Mike\Desktop\My Dropbox\School\CPSC315\Assignment4\flickr.py", line 324, in getPhotos
    p.append(Photo(photo.id, title=photo.title, secret=photo.secret, \
TypeError: iteration over non-sequence

It seems like line 19, photos = data.rsp.photoset.photo, isn't setting photos to be anything but I can't see why. Can anyone shed some light on this?


Whenever you have an error when dealing with someone else's code that they posted publicly that is relatively popular, it's good to assume that you're code has the error rather than their code. Does MyPhotoSets[0] contain a Photoset object? Maybe you should check.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.