【发布时间】:2012-11-15 20:59:41
【问题描述】:
我有一个 python 文件,其中包含 h1 和 img 和 strong 等函数,用于样式文本。每个函数的定义如下:
def _wrapTag(tag, text, **attributes):
out = _createTag(tag, **attributes)
out += text
out += "</" + tag + ">"
return out
def _createTag(tag, **attributes):
out = "<" + tag
if attributes:
for attr, value in attributes:
out += " " + attr + "=\"" + value + "\""
out += ">"
return out
def h2(text, **attributes):
return _wrapTag("h2", text, **attributes)
在理想情况下,要创建具有 modal 类的 div,我会调用 div(content, class="modal"),但 class 是受限制的关键字。有没有办法绕过这个而不给_createTag添加特殊情况?
【问题讨论】:
标签: python python-2.7 flask