I want to select a form with mechanize. This is my code:
br = mechanize.Browser() self.br.open(url) br.select_form(name=\"login_form\")
The for
a little more readable:
class Element_by_id: def __init__(self, id_text): self.id_text = id_text def __call__(self, f, *args, **kwargs): return 'id' in f.attrs and f.attrs['id'] ==self.id_text
then:
b.select_form(predicate=Element_by_id("login_form"))