def map(self, function, kind):
"""Applies a function to the ``data`` element of events of ``kind`` in
the selection.
>>> html = HTML('<html><head><title>Some Title</title></head>'
... '<body>Some <em>body</em> text.</body></html>',
... encoding='utf-8')
>>> print(html | Transformer('head/title').map(unicode.upper, TEXT))
<html><head><title>SOME TITLE</title></head><body>Some <em>body</em>
text.</body></html>
:param function: the function to apply
:param kind: the kind of event the function should be applied to
:rtype: `Transformer`
"""
return self.apply(MapTransformation(function, kind))
评论列表
文章目录