Skip to content

bpo-14465: Provide simple prett printing for XML and ETree API#8933

Closed
mcepl wants to merge 1 commit into
python:masterfrom
mcepl:14465_xml-pretty_print
Closed

bpo-14465: Provide simple prett printing for XML and ETree API#8933
mcepl wants to merge 1 commit into
python:masterfrom
mcepl:14465_xml-pretty_print

Conversation

@mcepl

@mcepl mcepl commented Aug 25, 2018

Copy link
Copy Markdown
Contributor

Comparing to the solution suggested in #4016, this should bear no performance penalty when pretty_print=False (which is the default). On the other hand, it is not suitable for processing of large XML data. Then some alternative solution (e.g., lxml module) must be used.

https://bugs.python.org/issue14465

Comparing to the solution suggested in #4016, this should bear no
performance penalty when pretty_print=False (which is the default). On
the other hand, it is not suitable for processing of large XML data.
Then some alternative solution (e.g., lxml module) must be used.
@mcepl

mcepl commented Aug 25, 2018

Copy link
Copy Markdown
Contributor Author

@scoder, what do you think?

enc_lower = encoding.lower()

if pretty_print:
self._indent(self._root)

@scoder scoder Aug 25, 2018

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, but write() is an output method. It shouldn't have side-effects that change the tree.
Just imagine you'd print or log the tree for debugging purposes and it would alter the serialised result later on.

@scoder

scoder commented Apr 14, 2019

Copy link
Copy Markdown
Contributor

Rejecting this PR in its current form, because it adds a side-effect to an otherwise pure output function.

@scoder scoder closed this Apr 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants