Next / Previous / Contents / TCC Help System / NM Tech homepage

50. FOR(): Build a “for=” attribute

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.

cbchistlib.py
# - - -   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!")