Compare commits
2 Commits
ff51e5ec26
...
aef482f7cf
Author | SHA1 | Date |
---|---|---|
Miss Islington (bot) | aef482f7cf | |
Julien Palard | 7e80c0f40e |
|
@ -266,7 +266,6 @@ Below are some examples of typical usage of the :mod:`bz2` module.
|
|||
Using :func:`compress` and :func:`decompress` to demonstrate round-trip compression:
|
||||
|
||||
>>> import bz2
|
||||
|
||||
>>> data = b"""\
|
||||
... Donec rhoncus quis sapien sit amet molestie. Fusce scelerisque vel augue
|
||||
... nec ullamcorper. Nam rutrum pretium placerat. Aliquam vel tristique lorem,
|
||||
|
@ -275,11 +274,9 @@ Using :func:`compress` and :func:`decompress` to demonstrate round-trip compress
|
|||
... Aliquam pharetra lacus non risus vehicula rutrum. Maecenas aliquam leo
|
||||
... felis. Pellentesque semper nunc sit amet nibh ullamcorper, ac elementum
|
||||
... dolor luctus. Curabitur lacinia mi ornare consectetur vestibulum."""
|
||||
|
||||
>>> c = bz2.compress(data)
|
||||
>>> len(data) / len(c) # Data compression ratio
|
||||
1.513595166163142
|
||||
|
||||
>>> d = bz2.decompress(c)
|
||||
>>> data == d # Check equality to original object after round-trip
|
||||
True
|
||||
|
@ -287,7 +284,6 @@ Using :func:`compress` and :func:`decompress` to demonstrate round-trip compress
|
|||
Using :class:`BZ2Compressor` for incremental compression:
|
||||
|
||||
>>> import bz2
|
||||
|
||||
>>> def gen_data(chunks=10, chunksize=1000):
|
||||
... """Yield incremental blocks of chunksize bytes."""
|
||||
... for _ in range(chunks):
|
||||
|
@ -310,7 +306,6 @@ while ordered, repetitive data usually yields a high compression ratio.
|
|||
Writing and reading a bzip2-compressed file in binary mode:
|
||||
|
||||
>>> import bz2
|
||||
|
||||
>>> data = b"""\
|
||||
... Donec rhoncus quis sapien sit amet molestie. Fusce scelerisque vel augue
|
||||
... nec ullamcorper. Nam rutrum pretium placerat. Aliquam vel tristique lorem,
|
||||
|
@ -319,14 +314,11 @@ Writing and reading a bzip2-compressed file in binary mode:
|
|||
... Aliquam pharetra lacus non risus vehicula rutrum. Maecenas aliquam leo
|
||||
... felis. Pellentesque semper nunc sit amet nibh ullamcorper, ac elementum
|
||||
... dolor luctus. Curabitur lacinia mi ornare consectetur vestibulum."""
|
||||
|
||||
>>> with bz2.open("myfile.bz2", "wb") as f:
|
||||
... # Write compressed data to file
|
||||
... unused = f.write(data)
|
||||
|
||||
>>> with bz2.open("myfile.bz2", "rb") as f:
|
||||
... # Decompress data from file
|
||||
... content = f.read()
|
||||
|
||||
>>> content == data # Check equality to original object after round-trip
|
||||
True
|
||||
|
|
|
@ -115,7 +115,7 @@ Protocol) and :rfc:`1869` (SMTP Service Extensions).
|
|||
If the *timeout* parameter is set to be zero, it will raise a
|
||||
:class:`ValueError` to prevent the creation of a non-blocking socket
|
||||
|
||||
.. class:: LMTP(host='', port=LMTP_PORT, local_hostname=None,
|
||||
.. class:: LMTP(host='', port=LMTP_PORT, local_hostname=None, \
|
||||
source_address=None[, timeout])
|
||||
|
||||
The LMTP protocol, which is very similar to ESMTP, is heavily based on the
|
||||
|
|
|
@ -132,7 +132,7 @@ module documentation. This section lists the differences between the API and
|
|||
... # Work with dom.
|
||||
|
||||
|
||||
.. method:: Node.writexml(writer, indent="", addindent="", newl="",
|
||||
.. method:: Node.writexml(writer, indent="", addindent="", newl="", \
|
||||
encoding=None, standalone=None)
|
||||
|
||||
Write XML to the writer object. The writer receives texts but not bytes as input,
|
||||
|
@ -174,7 +174,7 @@ module documentation. This section lists the differences between the API and
|
|||
The :meth:`toxml` method now preserves the attribute order specified
|
||||
by the user.
|
||||
|
||||
.. method:: Node.toprettyxml(indent="\\t", newl="\\n", encoding=None,
|
||||
.. method:: Node.toprettyxml(indent="\\t", newl="\\n", encoding=None, \
|
||||
standalone=None)
|
||||
|
||||
Return a pretty-printed version of the document. *indent* specifies the
|
||||
|
|
Loading…
Reference in New Issue