Skip to content

Commit 5025b51

Browse files
committed
Merge branch 'master' of github.com:msgpack/msgpack-python
2 parents d14a788 + 3594763 commit 5025b51

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

README.rst

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ MessagePack for Python
88

99
.. image:: https://secure.travis-ci.org/msgpack/msgpack-python.png
1010
:target: https://travis-ci.org/#!/msgpack/msgpack-python
11+
12+
.. image:: https://pypip.in/version/msgpack-python/badge.svg
13+
:target: https://pypi.python.org/pypi/msgpack-python/
14+
:alt: Latest Version
1115

1216
What's this
1317
------------
@@ -52,6 +56,8 @@ It is non-string binary like Python 3's ``bytes``.
5256
To use *bin* type for packing ``bytes``, pass ``use_bin_type=True`` to
5357
packer argument.
5458

59+
.. code-block:: pycon
60+
5561
>>> import msgpack
5662
>>> packed = msgpack.packb([b'spam', u'egg'], use_bin_type=True)
5763
>>> msgpack.unpackb(packed, encoding='utf-8')
@@ -62,6 +68,8 @@ binary can be unpacked by unpackers supporting msgpack-2.0.
6268

6369
To use *ext* type, pass ``msgpack.ExtType`` object to packer.
6470

71+
.. code-block:: pycon
72+
6573
>>> import msgpack
6674
>>> packed = msgpack.packb(msgpack.ExtType(42, b'xyzzy'))
6775
>>> msgpack.unpackb(packed)
@@ -95,15 +103,17 @@ msgpack provides ``dumps`` and ``loads`` as alias for compatibility with
95103
``pack`` and ``dump`` packs to file-like object.
96104
``unpack`` and ``load`` unpacks from file-like object.
97105

98-
::
106+
.. code-block:: pycon
99107
100108
>>> import msgpack
101109
>>> msgpack.packb([1, 2, 3])
102110
'\x93\x01\x02\x03'
103111
>>> msgpack.unpackb(_)
104112
[1, 2, 3]
105113
106-
``unpack`` unpacks msgpack's array to Python's list, but can unpack to tuple::
114+
``unpack`` unpacks msgpack's array to Python's list, but can unpack to tuple:
115+
116+
.. code-block:: pycon
107117
108118
>>> msgpack.unpackb(b'\x93\x01\x02\x03', use_list=False)
109119
(1, 2, 3)
@@ -119,7 +129,7 @@ Streaming unpacking
119129
``Unpacker`` is a "streaming unpacker". It unpacks multiple objects from one
120130
stream (or from bytes provided through its ``feed`` method).
121131

122-
::
132+
.. code-block:: python
123133
124134
import msgpack
125135
from io import BytesIO
@@ -141,7 +151,7 @@ Packing/unpacking of custom data type
141151
It is also possible to pack/unpack custom data types. Here is an example for
142152
``datetime.datetime``.
143153

144-
::
154+
.. code-block:: python
145155
146156
import datetime
147157
@@ -175,6 +185,8 @@ Extended types
175185

176186
It is also possible to pack/unpack custom data types using the msgpack 2.0 feature.
177187

188+
.. code-block:: pycon
189+
178190
>>> import msgpack
179191
>>> import array
180192
>>> def default(obj):
@@ -209,7 +221,7 @@ in a map, can be unpacked or skipped individually.
209221
Each of these methods may optionally write the packed data it reads to a
210222
callback function:
211223

212-
::
224+
.. code-block:: python
213225
214226
from io import BytesIO
215227

0 commit comments

Comments
 (0)