[Numpy-discussion] numpydoc for python 3?
Mon Jan 14 05:04:57 CST 2013
Le 14/01/2013 11:35, Jaakko Luttinen a écrit :
> Ok, thanks, maybe I'll try to make the tests valid in all Python
> versions. It seems there's only one line which I'm not able to transform.
> In doc/sphinxext/tests/test_docscrape.py, on line 559:
> assert doc['Summary'] == u'öäöäöäöäöåååå'.encode('utf-8')
> This is invalid in Python 3.0-3.2. How could I write this in such a way
> that it is valid in all Python versions? I'm a bit lost with these
> unicode encodings in Python (and in general).. And I didn't want to add
> dependency on 'six' package.
Just as a side note about Python and encodings, I found great help in
watching (by chance) the PyCon 2012 presentation "Pragmatic Unicode or
How do I stop the Pain ?" by Ned Batchelder :
Now, if I understand the problem correctly, the u'xxx' syntax was
reintroduced in Python 3.3 specifically to enhance the 2to3
Maybe the question is then whether it's worth supporting Python 3.0-3.2
or not ?
Also, one possible rewrite of the test could be to replace the unicode
string with the corresponding utf8-encoded bytes :
assert doc['Summary'] ==
# output of 'öäöäöäöäöåååå'.encode('utf-8')
(One restriction : I think the b'' prefix was introduced in Python 2.6)
I'm not sure for the readability though...
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 900 bytes
Desc: OpenPGP digital signature
Url : http://mail.scipy.org/pipermail/numpy-discussion/attachments/20130114/d565df29/attachment.bin
More information about the NumPy-Discussion