Structure Generation¶
It can be tedious to type out a structure. Luckily datatyping comes with a useful submodule for that called printer.
>>> from datatyping.printer import pprint
>>> import requests
>>> r = requests.get('http://httpbin.org/anything')
>>> pprint(r.json())
{
'args': dict,
'data': str,
'files': dict,
'form': dict,
'headers': {
'Accept': str,
'Accept-Encoding': str,
'Connection': str,
'Host': str,
'User-Agent': str,
},
'json': NoneType,
'method': str,
'origin': str,
'url': str,
}
Printer module¶
Like pprint, but with types except for dictionary keys.
-
datatyping.printer.
pprint
(object, stream=None, indent=4, width=80, depth=None, compact=False)¶ Pretty-prints the data structure.
-
datatyping.printer.
pformat
(object, indent=4, width=80, depth=None, compact=False)¶ Return the pretty printed data structure of object.