summaryrefslogtreecommitdiffstats
path: root/Lib/xml/etree
diff options
context:
space:
mode:
authorEli Bendersky <eliben@gmail.com>2013-01-13 14:27:51 (GMT)
committerEli Bendersky <eliben@gmail.com>2013-01-13 14:27:51 (GMT)
commite9af827fb1682a2378d189b4e7cb8ead405a991b (patch)
treeb2100d6308f74a95507583435381a732cc824572 /Lib/xml/etree
parent31efc746d5bdb82247ee44b8e16b6837342dc6e2 (diff)
downloadcpython-e9af827fb1682a2378d189b4e7cb8ead405a991b.zip
cpython-e9af827fb1682a2378d189b4e7cb8ead405a991b.tar.gz
cpython-e9af827fb1682a2378d189b4e7cb8ead405a991b.tar.bz2
Cleanup the docs ElementTree a bit and describe the default_namespace parameter. In the code, replace the old outdated Doxygen-ish comment above ElementTree.write by a proper docstring.
Diffstat (limited to 'Lib/xml/etree')
-rw-r--r--Lib/xml/etree/ElementTree.py28
1 files changed, 14 insertions, 14 deletions
diff --git a/Lib/xml/etree/ElementTree.py b/Lib/xml/etree/ElementTree.py
index 78a82e9..eab0a4f 100644
--- a/Lib/xml/etree/ElementTree.py
+++ b/Lib/xml/etree/ElementTree.py
@@ -779,26 +779,26 @@ class ElementTree:
)
return self._root.iterfind(path, namespaces)
- ##
- # Writes the element tree to a file, as XML.
- #
- # @def write(file, **options)
- # @param file A file name, or a file object opened for writing.
- # @param **options Options, given as keyword arguments.
- # @keyparam encoding Optional output encoding (default is US-ASCII).
- # Use "unicode" to return a Unicode string.
- # @keyparam method Optional output method ("xml", "html", "text" or
- # "c14n"; default is "xml").
- # @keyparam xml_declaration Controls if an XML declaration should
- # be added to the file. Use False for never, True for always,
- # None for only if not US-ASCII or UTF-8 or Unicode. None is default.
-
def write(self, file_or_filename,
encoding=None,
xml_declaration=None,
default_namespace=None,
method=None, *,
short_empty_elements=True):
+ """Write the element tree to a file, as XML. 'file_or_filename' is a
+ file name or a file object opened for writing. 'encoding' is the
+ output encoding (default is US-ASCII). 'xml_declaration' controls
+ if an XML declaration should be added to the output. Use False
+ for never, True for always, None for only if not US-ASCII or
+ UTF-8 or Unicode (default is None). 'method' is either "xml"
+ (default), "html", "text" or "c14n".
+ 'default_namespace' sets the default XML namespace (for "xmlns").
+ The keyword-only 'short_empty_elements' parameter controls the
+ formatting of elements that contain no content. If True (default),
+ they are emitted as a single self-closed tag, otherwise they are
+ emitted as a pair of start/end tags.
+
+ """
if not method:
method = "xml"
elif method not in _serialize: