prettytable icon indicating copy to clipboard operation
prettytable copied to clipboard

constructor formatting is overridden by get_string()

Open mzagrabe opened this issue 6 years ago • 0 comments

I create a PrettyTable as such:

#!/usr/bin/python3

from prettytable import PrettyTable

t = PrettyTable( header = False, border = False, padding_width = 0, )

t.add_row(['a', 'b', 'c', 'd',])

print(t) print(t.get_string(padding_width = 0))

and run it:

$ python3 prettytest a b c d abcd

I would expect the stringify of the table, "print(t)", would use the formatting option of "padding_width=0" to print it, but it is clear that the get_string() doesn't use the constructor's formatting options.

a b c d

If you manually set the padding_width for the get_string call, then the desired results is achieved:

abcd

The two print calls in the above example should yield the same results.

Thanks!

mzagrabe avatar Mar 26 '18 18:03 mzagrabe