python-tabulate
python-tabulate copied to clipboard
Add Argument for setting PRESERVE_WHITESPACE to True or False to tabulate
The option to whether or not to preserve leading/trailing whitespace in data is hardcoded to False by default. I would like the option to preserve the whitespace when making a table using the tabulate function.
line 72 of tabulate.py
Thanks!
When I need to preserve whitespace, I just set the flag you found:
import tabulate
tabulate.PRESERVE_WHITESPACE = True
table = [["Earth", 6371],
[" Mars", 3390],
["Moon", 1737]]
print(tabulate.tabulate(table, tablefmt="simple"))