How does a Python for loop with iterable work?
feed.entry is property of feed and it's value is (if it's not, this code will fail) object implementing iteration protocol (array, for example) and has iter method, which returns iterator object
Iterator has next() method, returning next element or raising exception, so python for loop is actually:
iterator = feed.entry.__iter__()
while True:
try:
party = iterator.next()
except StopIteration:
# StopIteration exception is raised after last element
break
# loop code
print party.location.address.text
feed.entry is something that allows iteration, and contains objects of some type. This is roughly similar to c++:
for (feed::iterator party = feed.entry.begin(); party != feed.entry.end(); ++party) {
cout << (*party).location.address.text;
}
To add my 0.05$ to the previous answers you might also want to take a look at the enumerate builtin function
for i, season in enumerate(['Spring', 'Summer', 'Fall', 'Winter']):
print i, season
0 Spring
1 Summer
2 Fall
3 Winter