Because “for” is a reserved word in
Python, we cannot attach a for attribute to
an XML element by using a “for=...”
argument to the E element factory.
Therefore, this function builds a dictionary with one element
mapping "for" to the given value. This
dictionary can be included as a positional argument in a call to
the E factory.
# - - - F O R
def FOR(id):
'''Used to attach 'for=...' attributes to a <label> element
'''
return {'for': id}
For example, to generate this XML:
<label for='some-id'>Check this if you dare!</label>
you could use this code:
E.label(FOR('some-id'), "Check this if you dare!")