summaryrefslogtreecommitdiff
path: root/tablib/core.py
diff options
context:
space:
mode:
authorKenneth Reitz <me@kennethreitz.com>2012-11-15 18:56:50 -0800
committerKenneth Reitz <me@kennethreitz.com>2012-11-15 18:56:50 -0800
commit9f38efe4133f6f4c4a2e58b5867f3f7883d119c8 (patch)
tree9dea315df1aff6c934114b6a31a676d05f3c9dc3 /tablib/core.py
parent5d98239a7e988a1a16261c6cb7073d618b92cfc7 (diff)
parent15435047c668aa8e1fb5ffc1a8db30e5b944d5fd (diff)
downloadtablib-9f38efe4133f6f4c4a2e58b5867f3f7883d119c8.tar.gz
Merge pull request #68 from msabramo/python3
Improve Python 3 compatibility
Diffstat (limited to 'tablib/core.py')
-rw-r--r--tablib/core.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/tablib/core.py b/tablib/core.py
index 1fdc77c..cb192ae 100644
--- a/tablib/core.py
+++ b/tablib/core.py
@@ -226,19 +226,21 @@ class Dataset(object):
def __unicode__(self):
result = [self.__headers]
- result.extend(map(unicode, row) for row in self._data)
+ result.extend(list(map(unicode, row)) for row in self._data)
# here, we calculate max width for each column
- lens = (map(len, row) for row in result)
- field_lens = map(max, zip(*lens))
+ lens = (list(map(len, row)) for row in result)
+ field_lens = list(map(max, zip(*lens)))
# delimiter between header and data
- result.insert(1, [u'-' * length for length in field_lens])
+ result.insert(1, ['-' * length for length in field_lens])
- format_string = u'|'.join(u'{%s:%s}' % item for item in enumerate(field_lens))
+ format_string = '|'.join('{%s:%s}' % item for item in enumerate(field_lens))
- return u'\n'.join(format_string.format(*row) for row in result)
+ return '\n'.join(format_string.format(*row) for row in result)
+ def __str__(self):
+ return self.__unicode__()
# ---------