attrs dictionary from py:match

2 views
Skip to first unread message

mikelin

unread,
Jul 11, 2008, 1:48:00 PM7/11/08
to Genshi
Hi, I need to get a dictionary of attributes from an element that I've
matched with a py:match.

Presumably I start with select('@*')?

I looked at AttrsDirective to see how py:attrs does it, but it's
looking pretty complicated. Anyone know an easy way to do this?

Mike

mikelin

unread,
Jul 17, 2008, 11:03:25 AM7/17/08
to Genshi
For posterity, I eventually came up with this from looking at
AttrsDirective:

<?python
try:
kind, (tag, attrs), pos = iter(select('//.')).next()
except StopIteration:
attrs = []
attrs = dict(attrs)
?>
Reply all
Reply to author
Forward
0 new messages