Skip to content

Commit

Permalink
add use_tuple unpacking option usage to readme
Browse files Browse the repository at this point in the history
  • Loading branch information
vsergeev committed Mar 1, 2020
1 parent 6d514f9 commit 4a3dabd
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,18 @@ OrderedDict([('compact', True), ('schema', 0)])
>>>
```

## Tuples

The unpacking functions provide a `use_tuple` option to unpack MessagePack arrays into tuples, rather than lists.

``` python
>>> umsgpack.unpackb(b'\x93\xa1a\xc3\x92\x01\x92\x02\x03')
['a', True, [1, [2, 3]]]
>>> umsgpack.unpackb(b'\x93\xa1a\xc3\x92\x01\x92\x02\x03', use_tuple=True)
('a', True, (1, (2, 3)))
>>>
```

### Invalid UTF-8 Strings

The unpacking functions provide an `allow_invalid_utf8` option to unpack MessagePack strings with invalid UTF-8 into the `umsgpack.InvalidString` type, instead of throwing an exception. The `umsgpack.InvalidString` type is a subclass of `bytes`, and can be used like any other `bytes` object.
Expand Down

0 comments on commit 4a3dabd

Please sign in to comment.