def option(label, value=None, selected=None):
    """Returns HTML code for an option tag"""
    if value is None: value = label
    if value == selected:
        selected = 'selected="selected"'
    else:
        selected = ''
    if value:
        value = "value='%s'" % value
    else:
        value = ''
    return '<option %(selected)s %(value)s>%(label)s</option>\n' % locals()