from cStringIO import StringIO def HTMLmarkup(tag, text, **attributes): """ markups the text with the tag and attributes """ s = StringIO() s.write('<%s' % tag) for attribute, value in attributes.items(): s.write(' %s="%s"' % (attribute, value)) s.write('>%s' % (text, tag)) return s.getvalue() tags = [ 'b', 'body', 'html' ] for i in tags: globals()[i] = eval("lambda x, **y: HTMLmarkup('%s', x, **y)" % i) # globals()[i] = lambda x, **y: HTMLmarkup(i, x, **y)