Skip to content

Comments

Print regular UTF-8 string instead of bytes-string#26

Open
humdogm wants to merge 1 commit intohchasestevens:masterfrom
humdogm:master
Open

Print regular UTF-8 string instead of bytes-string#26
humdogm wants to merge 1 commit intohchasestevens:masterfrom
humdogm:master

Conversation

@humdogm
Copy link

@humdogm humdogm commented Apr 20, 2022

Printing a bytes string looks unreadable in the terminal
e.g.

b'<tag1>\n    <tag2/>\n</tag1>'

What we want is more like:

<tag1>
    <tag2/>
</tag1>

Specify encoding to do this

Works for both xml and lxml
https://docs.python.org/3/library/xml.etree.elementtree.html#xml.etree.ElementTree.tostring
https://lxml.de/3.6/api/lxml.etree-module.html#tostring

Printing a bytes string looks unreadable in the terminal
e.g.
b'<tag1>\n    <tag2/>\n</tag1>'
What we want is more like:
<tag1>
    <tag2/>
</tag1>
Specify encoding to do this

Works for both xml and lxml
https://docs.python.org/3/library/xml.etree.elementtree.html#xml.etree.ElementTree.tostring
https://lxml.de/3.6/api/lxml.etree-module.html#tostring
@spookylukey
Copy link

FYI, this is fixed in https://github.com/spookylukey/pyastgrep

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants