From e11e85456c8464258f3fa9c7ba062a1b74d2bcae Mon Sep 17 00:00:00 2001 From: renato <118692351+09s23jf038@users.noreply.github.com> Date: Mon, 27 Jan 2025 23:10:45 -0300 Subject: [PATCH] Zeroed padding when maxcolwidths/maxheadercolwidths (Fixes #354) --- tabulate/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tabulate/__init__.py b/tabulate/__init__.py index b15d7f0..50556fe 100644 --- a/tabulate/__init__.py +++ b/tabulate/__init__.py @@ -2203,7 +2203,7 @@ def tabulate( Tabulate will, by default, set the width of each column to the length of the longest element in that column. However, in situations where fields are expected to reasonably be too long to look good as a single line, tabulate can help automate - word wrapping long fields for you. Use the parameter `maxcolwidth` to provide a + word wrapping long fields for you. Use the parameter `maxcolwidths` to provide a list of maximal column widths >>> print(tabulate( \ @@ -2221,7 +2221,7 @@ def tabulate( | | | better if it is wrapped a bit | +------------+------------+-------------------------------+ - Header column width can be specified in a similar way using `maxheadercolwidth` + Header column width can be specified in a similar way using `maxheadercolwidths` """ @@ -2234,6 +2234,7 @@ def tabulate( list_of_lists, separating_lines = _remove_separating_lines(list_of_lists) if maxcolwidths is not None: + MIN_PADDING = 0 if type(maxcolwidths) is tuple: # Check if tuple, convert to list if so maxcolwidths = list(maxcolwidths) if len(list_of_lists): @@ -2251,6 +2252,7 @@ def tabulate( ) if maxheadercolwidths is not None: + MIN_PADDING = 0 num_cols = len(list_of_lists[0]) if isinstance(maxheadercolwidths, int): # Expand scalar for all columns maxheadercolwidths = _expand_iterable(