I’m new to mechanize in python and it would be nice if someone could explain why this happens?
import mechanize
br = mechanize.Browser()
a = br.open('http://www.google.co.in')
links = br.links()
for link in links:
print link.url
However when I do this again, nothing gets printed out
for link in links:
print link.url
Can someone explain this?
My best guess would be that maybe
br.links()returns a generator. And that means that it doesn’t return one big iterable, but is dynamic and waits for thenextto be called on it before returning the next value in the sequence, so unless you store the variable yourself into alist, then it is only usable once.