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?


Edited by chunalt787: n/a

8 Years
Discussion Span
Last Post by Mathhax0r

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.