Skip to content

Commit fbd5b76

Browse files
committed
improve formatting in readme and msgpack.org.md
1 parent 4a38332 commit fbd5b76

File tree

2 files changed

+31
-34
lines changed

2 files changed

+31
-34
lines changed

README.md

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
u-msgpack-python is a lightweight [MessagePack](http://msgpack.org/) serializer and deserializer module written in pure Python, compatible with both Python 2 and 3, as well CPython and PyPy implementations of Python. u-msgpack-python is fully compliant with the latest [MessagePack specification](https://github.com/msgpack/msgpack/blob/master/spec.md). In particular, it supports the new binary, UTF-8 string, and application-defined ext types.
44

5-
u-msgpack-python is currently distributed on PyPI: https://pypi.python.org/pypi/u-msgpack-python and as a single file: [umsgpack.py](https://raw.github.com/vsergeev/u-msgpack-python/master/umsgpack.py)
5+
u-msgpack-python is currently distributed on [PyPI](https://pypi.python.org/pypi/u-msgpack-python) and as a single file: [umsgpack.py](https://raw.github.com/vsergeev/u-msgpack-python/master/umsgpack.py).
66

77
## Installation
88

@@ -27,21 +27,21 @@ Basic Example:
2727
``` python
2828
>>> import umsgpack
2929
>>> umsgpack.packb({u"compact": True, u"schema": 0})
30-
'\x82\xa7compact\xc3\xa6schema\x00'
30+
b'\x82\xa7compact\xc3\xa6schema\x00'
3131
>>> umsgpack.unpackb(_)
3232
{u'compact': True, u'schema': 0}
3333
>>>
3434
```
3535

3636
A more complicated example:
3737
``` python
38-
>>> umsgpack.packb( [1, True, False, 0xffffffff, {u"foo": b"\x80\x01\x02",
39-
u"bar": [1,2,3, {u"a": [1,2,3,{}]}]}, -1, 2.12345] )
40-
'\x97\x01\xc3\xc2\xce\xff\xff\xff\xff\x82\xa3foo\xc4\x03\x80\x01'
41-
'\x02\xa3bar\x94\x01\x02\x03\x81\xa1a\x94\x01\x02\x03\x80\xff\xcb'
42-
'@\x00\xfc\xd3Z\x85\x87\x94'
38+
>>> umsgpack.packb([1, True, False, 0xffffffff, {u"foo": b"\x80\x01\x02", \
39+
... u"bar": [1,2,3, {u"a": [1,2,3,{}]}]}, -1, 2.12345])
40+
b'\x97\x01\xc3\xc2\xce\xff\xff\xff\xff\x82\xa3foo\xc4\x03\x80\x01\
41+
\x02\xa3bar\x94\x01\x02\x03\x81\xa1a\x94\x01\x02\x03\x80\xff\xcb\
42+
@\x00\xfc\xd3Z\x85\x87\x94'
4343
>>> umsgpack.unpackb(_)
44-
[1, True, False, 4294967295, {u'foo': '\x80\x01\x02',
44+
[1, True, False, 4294967295, {u'foo': b'\x80\x01\x02', \
4545
u'bar': [1, 2, 3, {u'a': [1, 2, 3, {}]}]}, -1, 2.12345]
4646
>>>
4747
```
@@ -62,19 +62,19 @@ Streaming serialization with file-like objects:
6262
>>>
6363
```
6464

65-
Encoding and decoding an application-defined Ext type:
65+
Encoding and decoding a raw Ext type:
6666
``` python
67-
# Create an Ext object with type 0x05 and data b"\x01\x02\x03"
68-
>>> foo = umsgpack.Ext(0x05, b"\x01\x02\x03")
69-
>>> umsgpack.packb({u"special stuff": foo, u"awesome": True})
70-
b'\x82\xadspecial stuff\xc7\x03\x05\x01\x02\x03\xa7awesome\xc3'
67+
>>> # Create an Ext object with type 0x05 and data b"\x01\x02\x03"
68+
... foo = umsgpack.Ext(0x05, b"\x01\x02\x03")
69+
>>> umsgpack.packb({u"stuff": foo, u"awesome": True})
70+
b'\x82\xa5stuff\xc7\x03\x05\x01\x02\x03\xa7awesome\xc3'
7171
>>>
7272
>>> bar = umsgpack.unpackb(_)
73-
>>> print(bar["special stuff"])
73+
>>> print(bar['stuff'])
7474
Ext Object (Type: 0x05, Data: 0x01 0x02 0x03)
75-
>>> bar["special stuff"].type
75+
>>> bar['stuff'].type
7676
5
77-
>>> bar["special stuff"].data
77+
>>> bar['stuff'].data
7878
b'\x01\x02\x03'
7979
>>>
8080
```
@@ -98,9 +98,8 @@ b'\x92\xd70\x00\x00\x80?\x00\x00\x00@\xc7\x18@20161017T00:12:53.719377'
9898

9999
Python standard library style names `dump`, `dumps`, `load`, `loads` are also available:
100100
``` python
101-
>>> import umsgpack
102101
>>> umsgpack.dumps({u"compact": True, u"schema": 0})
103-
'\x82\xa7compact\xc3\xa6schema\x00'
102+
b'\x82\xa7compact\xc3\xa6schema\x00'
104103
>>> umsgpack.loads(_)
105104
{u'compact': True, u'schema': 0}
106105
>>>

msgpack.org.md

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Basic Example:
2727
``` python
2828
>>> import umsgpack
2929
>>> umsgpack.packb({u"compact": True, u"schema": 0})
30-
'\x82\xa7compact\xc3\xa6schema\x00'
30+
b'\x82\xa7compact\xc3\xa6schema\x00'
3131
>>> umsgpack.unpackb(_)
3232
{u'compact': True, u'schema': 0}
3333
>>>
@@ -36,13 +36,13 @@ Basic Example:
3636
A more complicated example:
3737
``` python
3838
>>> umsgpack.packb(
39-
[1, True, False, 0xffffffff, {u"foo": b"\x80\x01\x02",
40-
u"bar": [1,2,3, {u"a": [1,2,3,{}]}]}, -1, 2.12345] )
41-
'\x97\x01\xc3\xc2\xce\xff\xff\xff\xff\x82\xa3foo\xc4\x03\x80\x01'
42-
'\x02\xa3bar\x94\x01\x02\x03\x81\xa1a\x94\x01\x02\x03\x80\xff\xcb'
43-
'@\x00\xfc\xd3Z\x85\x87\x94'
39+
... [1, True, False, 0xffffffff, {u"foo": b"\x80\x01\x02",
40+
... u"bar": [1,2,3, {u"a": [1,2,3,{}]}]}, -1, 2.12345] )
41+
b'\x97\x01\xc3\xc2\xce\xff\xff\xff\xff\x82\xa3foo\xc4\x03\x80\x01\
42+
\x02\xa3bar\x94\x01\x02\x03\x81\xa1a\x94\x01\x02\x03\x80\xff\xcb\
43+
@\x00\xfc\xd3Z\x85\x87\x94'
4444
>>> umsgpack.unpackb(_)
45-
[1, True, False, 4294967295, {u'foo': '\x80\x01\x02',
45+
[1, True, False, 4294967295, {u'foo': b'\x80\x01\x02', \
4646
u'bar': [1, 2, 3, {u'a': [1, 2, 3, {}]}]}, -1, 2.12345]
4747
>>>
4848
```
@@ -63,19 +63,19 @@ Streaming serialization with file-like objects:
6363
>>>
6464
```
6565

66-
Encoding and decoding an application-defined ext type:
66+
Encoding and decoding a raw Ext type:
6767
``` python
6868
>>> # Create an Ext object with type 0x05 and data b"\x01\x02\x03"
6969
... foo = umsgpack.Ext(0x05, b"\x01\x02\x03")
70-
>>> umsgpack.packb({u"special stuff": foo, u"awesome": True})
71-
b'\x82\xadspecial stuff\xc7\x03\x05\x01\x02\x03\xa7awesome\xc3'
70+
>>> umsgpack.packb({u"stuff": foo, u"awesome": True})
71+
b'\x82\xa5stuff\xc7\x03\x05\x01\x02\x03\xa7awesome\xc3'
7272
>>>
7373
>>> bar = umsgpack.unpackb(_)
74-
>>> print(bar["special stuff"])
74+
>>> print(bar['stuff'])
7575
Ext Object (Type: 0x05, Data: 0x01 0x02 0x03)
76-
>>> bar["special stuff"].type
76+
>>> bar['stuff'].type
7777
5
78-
>>> bar["special stuff"].data
78+
>>> bar['stuff'].data
7979
b'\x01\x02\x03'
8080
>>>
8181
```
@@ -107,11 +107,9 @@ b'19377'
107107

108108
Python standard library style names `dump`, `dumps`, `load`, `loads` are also
109109
available:
110-
111110
``` python
112-
>>> import umsgpack
113111
>>> umsgpack.dumps({u"compact": True, u"schema": 0})
114-
'\x82\xa7compact\xc3\xa6schema\x00'
112+
b'\x82\xa7compact\xc3\xa6schema\x00'
115113
>>> umsgpack.loads(_)
116114
{u'compact': True, u'schema': 0}
117115
>>>

0 commit comments

Comments
 (0)