Ron Angeles schrieb am 18.09.2014 um 09:14:
> xmlCoreDepthFirstItertor and xmlCoreBreadthFirstItertor only
> implement a python2-compatible iterator interface. The necessary
> method names (__next__) have been added. They just passthrough
> to the python2 method (next).
> ---
> python/libxml.py | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/python/libxml.py b/python/libxml.py
> index e507e0f..abf0cd4 100644
> --- a/python/libxml.py
> +++ b/python/libxml.py
> @@ -530,6 +530,10 @@ class xmlCoreDepthFirstItertor:
> self.parents = []
> def __iter__(self):
> return self
> + # python3 iterator
> + def __next__(self):
> + return self.next()
> + # python2 iterator
> def next(self):
> while 1:
> if self.node:
You can write
__next__ = next
below the "next" method in both cases. No need to go through an indirection
here. I'd even reverse it: change the method definition to "__next__(self)"
and add a "next" alias instead of the above.
Also note that there is a Python package called "lxml" (developed by me)
that wraps libxml2 and libxslt. People tend to prefer it over the bare
Python bindings that come with both libraries.
Stefan
_______________________________________________
xml mailing list, project page http://xmlsoft.org/
[email protected]
https://mail.gnome.org/mailman/listinfo/xml