Created
January 10, 2010 02:03
-
-
Save daeken/273284 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def select(name, cur=None, options=()): | |
options = ((v, v) if isinstance(v, str) else v for v in options) | |
return '<select name="%s">%s</select>' % ( | |
name, | |
''.join('<option%s%s>%s</option>' % ( | |
' selected' if cur == value else '', | |
(' value="%s"' % value) if value != name else '', | |
name | |
) for value, name in options) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment