Stefan Behnel wrote:

> Andrew Z schrieb am 07.03.2018 um 05:03:
>> Hello,
>>  with 3.6 and latest greatest lxml:
>> 
>> from lxml import etree
>> 
>> tree = etree.parse('Sample.xml')
>> etree.register_namespace('','http://www.example.com')
> 
> The default namespace prefix is spelled None (because there is no prefix
> for it) and not the empty string.

Does that mean the OP shouldn't use register_namespace() at all or that he's 
supposed to replace "" with None?

If the latter -- it looks like None accepted either:

(lxml_again)$ python
Python 3.4.3 (default, Nov 28 2017, 16:41:13) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from lxml import etree
>>> etree.register_namespace(None, "http://www.example.com";)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "src/lxml/etree.pyx", line 200, in lxml.etree.register_namespace 
(src/lxml/etree.c:11612)
  File "src/lxml/apihelpers.pxi", line 1442, in lxml.etree._utf8 
(src/lxml/etree.c:32933)
TypeError: Argument must be bytes or unicode, got 'NoneType'
>>> etree.__version__
'4.1.1'


-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to