@@ -65,7 +65,7 @@ and outputs a nicely formatted plain-text table::
65
65
66
66
>>> table = [["Sun",696000,1989100000],["Earth",6371,5973.6],
67
67
... ["Moon",1737,73.5],["Mars",3390,641.85]]
68
- >>> print tabulate(table)
68
+ >>> print( tabulate(table) )
69
69
----- ------ -------------
70
70
Sun 696000 1.9891e+09
71
71
Earth 6371 5973.6
@@ -91,7 +91,7 @@ Headers
91
91
The second optional argument named ``headers `` defines a list of
92
92
column headers to be used::
93
93
94
- >>> print tabulate(table, headers=["Planet","R (km)", "mass (x 10^29 kg)"])
94
+ >>> print( tabulate(table, headers=["Planet","R (km)", "mass (x 10^29 kg)"]) )
95
95
Planet R (km) mass (x 10^29 kg)
96
96
-------- -------- -------------------
97
97
Sun 696000 1.9891e+09
@@ -101,8 +101,8 @@ column headers to be used::
101
101
102
102
If ``headers="firstrow" ``, then the first row of data is used::
103
103
104
- >>> print tabulate([["Name","Age"],["Alice",24],["Bob",19]],
105
- ... headers="firstrow")
104
+ >>> print( tabulate([["Name","Age"],["Alice",24],["Bob",19]],
105
+ ... headers="firstrow"))
106
106
Name Age
107
107
------ -----
108
108
Alice 24
@@ -113,8 +113,8 @@ If ``headers="keys"``, then the keys of a dictionary/dataframe, or
113
113
column indices are used. It also works for NumPy record arrays and
114
114
lists of dictionaries or named tuples::
115
115
116
- >>> print tabulate({"Name": ["Alice", "Bob"],
117
- ... "Age": [24, 19]}, headers="keys")
116
+ >>> print( tabulate({"Name": ["Alice", "Bob"],
117
+ ... "Age": [24, 19]}, headers="keys"))
118
118
Age Name
119
119
----- ------
120
120
24 Alice
@@ -171,7 +171,7 @@ Supported table formats are:
171
171
172
172
>>> table = [["spam",42],["eggs",451],["bacon",0]]
173
173
>>> headers = ["item", "qty"]
174
- >>> print tabulate(table, headers, tablefmt="plain")
174
+ >>> print( tabulate(table, headers, tablefmt="plain") )
175
175
item qty
176
176
spam 42
177
177
eggs 451
@@ -181,7 +181,7 @@ Supported table formats are:
181
181
versions). It corresponds to ``simple_tables `` in `Pandoc Markdown
182
182
extensions `_::
183
183
184
- >>> print tabulate(table, headers, tablefmt = " simple" )
184
+ >>> print ( tabulate(table, headers, tablefmt = " simple" ) )
185
185
item qty
186
186
------ -----
187
187
spam 42
@@ -192,7 +192,7 @@ extensions`_::
192
192
package. It corresponds to ``grid_tables `` in Pandoc Markdown
193
193
extensions::
194
194
195
- >>> print tabulate(table, headers, tablefmt="grid")
195
+ >>> print( tabulate(table, headers, tablefmt="grid") )
196
196
+--------+-------+
197
197
| item | qty |
198
198
+========+=======+
@@ -205,7 +205,7 @@ extensions::
205
205
206
206
``fancy_grid `` draws a grid using box-drawing characters::
207
207
208
- >>> print tabulate(table, headers, tablefmt="fancy_grid")
208
+ >>> print( tabulate(table, headers, tablefmt="fancy_grid") )
209
209
╒════════╤═══════╕
210
210
│ item │ qty │
211
211
╞════════╪═══════╡
@@ -218,7 +218,7 @@ extensions::
218
218
219
219
``presto `` is like tables formatted by Presto cli::
220
220
221
- >>> print tabulate.tabulate()
221
+ >>> print( tabulate.tabulate() )
222
222
item | qty
223
223
--------+-------
224
224
spam | 42
@@ -227,7 +227,7 @@ extensions::
227
227
228
228
``psql `` is like tables formatted by Postgres' psql cli::
229
229
230
- >>> print tabulate.tabulate()
230
+ >>> print( tabulate.tabulate() )
231
231
+--------+-------+
232
232
| item | qty |
233
233
|--------+-------|
@@ -240,7 +240,7 @@ extensions::
240
240
corresponds to ``pipe_tables `` in Pandoc. This format uses colons to
241
241
indicate column alignment::
242
242
243
- >>> print tabulate(table, headers, tablefmt="pipe")
243
+ >>> print( tabulate(table, headers, tablefmt="pipe") )
244
244
| item | qty |
245
245
|:-------|------:|
246
246
| spam | 42 |
@@ -250,7 +250,7 @@ indicate column alignment::
250
250
``orgtbl `` follows the conventions of Emacs `org-mode `_, and is editable
251
251
also in the minor `orgtbl-mode `. Hence its name::
252
252
253
- >>> print tabulate(table, headers, tablefmt="orgtbl")
253
+ >>> print( tabulate(table, headers, tablefmt="orgtbl") )
254
254
| item | qty |
255
255
|--------+-------|
256
256
| spam | 42 |
@@ -259,15 +259,15 @@ also in the minor `orgtbl-mode`. Hence its name::
259
259
260
260
``jira `` follows the conventions of Atlassian Jira markup language::
261
261
262
- >>> print tabulate(table, headers, tablefmt="jira")
262
+ >>> print( tabulate(table, headers, tablefmt="jira") )
263
263
|| item || qty ||
264
264
| spam | 42 |
265
265
| eggs | 451 |
266
266
| bacon | 0 |
267
267
268
268
``rst `` formats data like a simple table of the `reStructuredText `_ format::
269
269
270
- >>> print tabulate(table, headers, tablefmt="rst")
270
+ >>> print( tabulate(table, headers, tablefmt="rst") )
271
271
====== =====
272
272
item qty
273
273
====== =====
@@ -279,7 +279,7 @@ also in the minor `orgtbl-mode`. Hence its name::
279
279
``mediawiki `` format produces a table markup used in `Wikipedia `_ and on
280
280
other MediaWiki-based sites::
281
281
282
- >>> print tabulate(table, headers, tablefmt="mediawiki")
282
+ >>> print( tabulate(table, headers, tablefmt="mediawiki") )
283
283
{| class="wikitable" style="text-align: left;"
284
284
|+ <!-- caption -->
285
285
|-
@@ -295,7 +295,7 @@ other MediaWiki-based sites::
295
295
``moinmoin `` format produces a table markup used in `MoinMoin `_
296
296
wikis::
297
297
298
- >>> print tabulate(d,headers,tablefmt="moinmoin")
298
+ >>> print( tabulate(d,headers,tablefmt="moinmoin") )
299
299
|| ''' item ''' || ''' quantity ''' ||
300
300
|| spam || 41.999 ||
301
301
|| eggs || 451 ||
@@ -304,23 +304,23 @@ wikis::
304
304
``youtrack `` format produces a table markup used in Youtrack
305
305
tickets::
306
306
307
- >>> print tabulate(d,headers,tablefmt="youtrack")
307
+ >>> print( tabulate(d,headers,tablefmt="youtrack") )
308
308
|| item || quantity ||
309
309
| spam | 41.999 |
310
310
| eggs | 451 |
311
311
| bacon | |
312
312
313
313
``textile `` format produces a table markup used in `Textile `_ format::
314
314
315
- >>> print tabulate(table, headers, tablefmt='textile')
315
+ >>> print( tabulate(table, headers, tablefmt='textile') )
316
316
|_. item |_. qty |
317
317
|<. spam |>. 42 |
318
318
|<. eggs |>. 451 |
319
319
|<. bacon |>. 0 |
320
320
321
321
``html `` produces standard HTML markup::
322
322
323
- >>> print tabulate(table, headers, tablefmt="html")
323
+ >>> print( tabulate(table, headers, tablefmt="html") )
324
324
<table>
325
325
<tbody>
326
326
<tr><th>item </th><th style="text-align: right;"> qty</th></tr>
@@ -334,7 +334,7 @@ tickets::
334
334
replacing special characters like ``_ `` or ``\ `` to their LaTeX
335
335
correspondents::
336
336
337
- >>> print tabulate(table, headers, tablefmt="latex")
337
+ >>> print( tabulate(table, headers, tablefmt="latex") )
338
338
\begin{tabular}{lr}
339
339
\hline
340
340
item & qty \\
@@ -378,7 +378,7 @@ You can override the default alignment with ``numalign`` and
378
378
Aligning by a decimal point works best when you need to compare
379
379
numbers at a glance::
380
380
381
- >>> print tabulate([[1.2345],[123.45],[12.345],[12345],[1234.5]])
381
+ >>> print( tabulate([[1.2345],[123.45],[12.345],[12345],[1234.5]]) )
382
382
----------
383
383
1.2345
384
384
123.45
@@ -389,7 +389,7 @@ numbers at a glance::
389
389
390
390
Compare this with a more common right alignment::
391
391
392
- >>> print tabulate([[1.2345],[123.45],[12.345],[12345],[1234.5]], numalign="right")
392
+ >>> print( tabulate([[1.2345],[123.45],[12.345],[12345],[1234.5]], numalign="right") )
393
393
------
394
394
1.2345
395
395
123.45
@@ -409,7 +409,7 @@ from a file:
409
409
>>> table = list(csv.reader(StringIO("spam, 42\neggs, 451\n")))
410
410
>>> table
411
411
[['spam', ' 42'], ['eggs', ' 451']]
412
- >>> print tabulate(table)
412
+ >>> print( tabulate(table) )
413
413
---- ----
414
414
spam 42
415
415
eggs 451
@@ -423,7 +423,7 @@ Number formatting
423
423
``tabulate `` allows to define custom number formatting applied to all
424
424
columns of decimal numbers. Use ``floatfmt `` named argument::
425
425
426
- >>> print tabulate([["pi",3.141593],["e",2.718282]], floatfmt=".4f")
426
+ >>> print( tabulate([["pi",3.141593],["e",2.718282]], floatfmt=".4f") )
427
427
-- ------
428
428
pi 3.1416
429
429
e 2.7183
@@ -432,7 +432,7 @@ columns of decimal numbers. Use ``floatfmt`` named argument::
432
432
``floatfmt `` argument can be a list or a tuple of format strings,
433
433
one per column, in which case every column may have different number formatting::
434
434
435
- >>> print tabulate([[0.12345, 0.12345, 0.12345]], floatfmt=(".1f", ".3f"))
435
+ >>> print( tabulate([[0.12345, 0.12345, 0.12345]], floatfmt=(".1f", ".3f") ))
436
436
--- ----- -------
437
437
0.1 0.123 0.12345
438
438
--- ----- -------
0 commit comments