summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authoryarko <yarkot1@gmail.com>2017-02-24 06:39:53 -0600
committerIuri de Silvio <iurisilvio@gmail.com>2017-02-24 09:39:53 -0300
commitc5c2dffe421e663155baa7fa9a90540f6974554c (patch)
tree3becf31ad82af34e5cb997f8415c9618358fb933 /docs
parent46102d4be718ee6fd6c003c1387df7c940e65b2c (diff)
downloadtablib-c5c2dffe421e663155baa7fa9a90540f6974554c.tar.gz
correct example (#276)
map() is a function in python2, and iterator in python3+; In any case - map is inefficient compared to either comprehensions (most efficient), or simple loops (close second). SInce in this case, data.append() returns nothing, use a simple look. It is clearer, more efficient, and works with both python2 and python3
Diffstat (limited to 'docs')
-rw-r--r--docs/index.rst4
1 files changed, 3 insertions, 1 deletions
diff --git a/docs/index.rst b/docs/index.rst
index 20103b6..55e5679 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -27,7 +27,9 @@ Tablib is an :ref:`MIT Licensed <mit>` format-agnostic tabular dataset library,
::
>>> data = tablib.Dataset(headers=['First Name', 'Last Name', 'Age'])
- >>> map(data.append, [('Kenneth', 'Reitz', 22), ('Bessie', 'Monke', 21)])
+ >>> for i in [('Kenneth', 'Reitz', 22), ('Bessie', 'Monke', 21)]:
+ ... data.append(i)
+
>>> print data.json
[{"Last Name": "Reitz", "First Name": "Kenneth", "Age": 22}, {"Last Name": "Monke", "First Name": "Bessie", "Age": 21}]