
On Tue, Mar 21, 2017 at 7:02 PM, Bob Kline <bkline@rksystems.com> wrote:
... Is there a more elegant way to do it ...?
Hmm. It appears that I'm in need of more than additional elegance here. When I actually tried to apply the approach I just described, I discovered that I'm not able to get to the context_node member of the context argument at all (not even to print its type), even though I can see that it's there (by looking at the output of print(dir(context))). def ext_function(context, arg=None): print(dir(context)) print(type(context.context_node)) .... The first print statement shows [..., 'context_node', 'eval_context'] but the second triggers an exception: .... print(type(context.context_node)) File "src\lxml\extensions.pxi", line 315, in lxml.etree._BaseContext.context_node.__get__ (src\lxml\lxml.etree.c:159971) File "src\lxml\lxml.etree.pyx", line 1617, in lxml.etree._elementFactory (src\lxml\lxml.etree.c:59684) File "src\lxml\classlookup.pxi", line 407, in lxml.etree._parser_class_lookup (src\lxml\lxml.etree.c:92440) File "src\lxml\classlookup.pxi", line 259, in lxml.etree._callLookupFallback (src\lxml\lxml.etree.c:90672) File "src\lxml\classlookup.pxi", line 338, in lxml.etree._lookupDefaultElementClass (src\lxml\lxml.etree.c:91744) AssertionError: Unknown node type: 9 I can't recall ever failing to print out the type of something which I can see is there. Any idea what's going on? Thanks, Bob