Representing complex object as unicode or simple string.
Project description
unilog
Representing complex object as unicode or simple string.
Installation
$ pip install unilog
Example
data = [
[
{
'dict1': 'dict1',
u'dict12': u'dict12'
},
[
1, 2, 3, 4, 5
],
(
'один', u'два', 'three', u'for', u'пять'
)
],
(
5, 4, 3, 2, 1.11
),
{
'list': ['item1', 'item2', u'пункт3'],
'tuple': tuple(('значение1', u'значение2', 'значение3')),
'dict': {
'date': datetime.date(2016, 12, 6),
'datetime': datetime.datetime(2016, 12, 6, 11, 22, 33, 444444),
'NoneType': None
}
}
]
# default python behavior
>>> print unicode(data)
[[{'dict1': 'dict1', u'dict12': u'dict12'}, [1, 2, 3, 4, 5], ('\xd0\xbe\xd0\xb4\xd0\xb8\xd0\xbd', u'\u0434\u0432\u0430', 'three', u'for', u'\u043f\u044f\u0442\u044c')], (5, 4, 3, 2, 1.11), {'dict': {'date': datetime.date(2016, 12, 6), 'NoneType': None, 'datetime': datetime.datetime(2016, 12, 6, 11, 22, 33, 444444)}, 'list': ['item1', 'item2', u'\u043f\u0443\u043d\u043a\u04423'], 'tuple': ('\xd0\xb7\xd0\xbd\xd0\xb0\xd1\x87\xd0\xb5\xd0\xbd\xd0\xb8\xd0\xb51', u'\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u04352', '\xd0\xb7\xd0\xbd\xd0\xb0\xd1\x87\xd0\xb5\xd0\xbd\xd0\xb8\xd0\xb53')}]
# use unilog.as_unicode function
>>> print unilog.as_unicode(data)
[[{'dict1': 'dict1', u'dict12': u'dict12'}, [1, 2, 3, 4, 5], ('один', u'два', 'three', u'for', u'пять')], (5, 4, 3, 2, 1.11), {'dict': {'date': 2016-12-06, 'NoneType': None, 'datetime': 2016-12-06 11:22:33.444444}, 'list': ['item1', 'item2', u'пункт3'], 'tuple': ('значение1', u'значение2', 'значение3')}]
License
MIT licensed. See the bundled LICENSE file for more details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
unilog-1.0.0.tar.gz
(2.9 kB
view hashes)