Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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