passing keyword arguments that are themselfs python keywords
Stefan Seefeld
seefeld at sympatico.ca
Mon Feb 5 14:43:08 EST 2001
Hi,
I'm trying to write a python function that can take keywords such as 'class'.
Is that possible ?
I'd like to be able to define something like:
def entity(type, body, **attr):
print '<' + type + ' ' + string.join(map(lambda item:', %s="%s"'%item, attr.items())) + '>'
print body
print '</type>'
and would like to call it like
entity('div', text, class='header')
Is there any way to achieve the desired effect ?
Thanks, Stefan
More information about the Python-list
mailing list