Closed SteffenBrinckmann closed 2 years ago
I edited your post to add examples of what you're after and what happens, I hope I got them right :)
PrettyTable has been doing this since at least the oldest testable version (0.6, May 2012) and probably forever, so at this point I suggest we adjust the documentation to reflect reality. Would you like to create a PR?
And for printing a table without an external border, we could add some new _char
options to override the existing ones, but only for the outer lines. So for example you could set it to " "
.
As an example of current chars:
from prettytable import PrettyTable
table = PrettyTable()
table.field_names = ["City name", "Area", "Population", "Annual Rainfall"]
table.add_rows(
[
["Adelaide", 1295, 1158259, 600.5],
["Brisbane", 5905, 1857594, 1146.4],
["Darwin", 112, 120900, 1714.7],
["Hobart", 1357, 205556, 619.5],
["Sydney", 2058, 4336374, 1214.8],
["Melbourne", 1566, 3806092, 646.9],
["Perth", 5386, 1554769, 869.4],
]
)
table.vertical_char = "!"
table.horizontal_char = "~"
table.junction_char = "*"
table.top_junction_char = "@"
table.bottom_junction_char = "#"
table.right_junction_char = "$"
table.left_junction_char = "%"
table.top_right_junction_char = "^"
table.top_left_junction_char = "&"
table.bottom_right_junction_char = "("
table.bottom_left_junction_char = ")"
print(table)
&~~~~~~~~~~~@~~~~~~@~~~~~~~~~~~~@~~~~~~~~~~~~~~~~~^
! City name ! Area ! Population ! Annual Rainfall !
%~~~~~~~~~~~*~~~~~~*~~~~~~~~~~~~*~~~~~~~~~~~~~~~~~$
! Adelaide ! 1295 ! 1158259 ! 600.5 !
! Brisbane ! 5905 ! 1857594 ! 1146.4 !
! Darwin ! 112 ! 120900 ! 1714.7 !
! Hobart ! 1357 ! 205556 ! 619.5 !
! Sydney ! 2058 ! 4336374 ! 1214.8 !
! Melbourne ! 1566 ! 3806092 ! 646.9 !
! Perth ! 5386 ! 1554769 ! 869.4 !
)~~~~~~~~~~~#~~~~~~#~~~~~~~~~~~~#~~~~~~~~~~~~~~~~~(
What do you think? Would you like to create a PR?
If one would only adopt the documentation, then one can turn off the borders all together via multiple methods, which leads to redundancy. I would really like to have no border on the outside.
If we change border = False
that would be a breaking change, and we don't know how many people that would affect, but this library is downloaded 5m a month, so I'd like to avoid sudden breaks.
Breaking changes are allowed, but they should have deprecation first, tricky in this case.
That's why I'm suggesting two things:
border = False
does now, and we don't change its functionality.That are very good points and make sense.
On Apr 19, 2022 at 17:30, Hugo van Kemenade @.***> wrote:
If we change border = False that would be a breaking change, and we don't know how many people that would affect, but this library is downloaded 5m a month, so I'd like to avoid sudden breaks.
Breaking changes are allowed, but they should have deprecation first, tricky in this case.
That's why I'm suggesting two things:
— Reply to this email directly, view it on GitHub https://github.com/jazzband/prettytable/issues/178#issuecomment-1102793600, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJMX6GUSR65HGEHTKZI4TY3VF3GPLANCNFSM5TX2BZIA . You are receiving this because you authored the thread.Message ID: @.***>
I'd be happy to create a PR for this if no one else is actively working on it yet.
A one line work-around to produce tables without outside borders.
print('\n'.join([i[1:-1] for i in table.get_string().split('\n')[1:-1]]))
String magic
Hi Guys,
A simple description like this may work?
"A boolean option (must be TrueorFalse). Controls whether border lines are drawn around and inside the table."
What did you do?
What did you expect to happen?
As stated: "Controls whether a border is drawn around the table." I wanted to keep the lines in the middle of the table but not the lines on the outside.
What actually happened?
All lines disappeared
What versions are you using?
Please include code that reproduces the issue.
The best reproductions are self-contained scripts with minimal dependencies.