We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add_divider
I would like to avoid detecting the last item of a loop to add a divider. Therefore I would like to be able to set it separately, see example.
import prettytable tab = prettytable.PrettyTable() for s in ["a", "b", "c"]: tab.add_row([s, s]) tab.add_divider() for s in ["1", "2", "3"]: tab.add_row([s, s]) print(tab.get_string())
import prettytable tab = prettytable.PrettyTable() rows = ["a", "b", "c"] for i, s in enumerate(rows): tab.add_row([s, s], divider=i == len(rows) - 1) rows = ["1", "2", "3"] for i, s in enumerate(rows): tab.add_row([s, s], divider=i == len(rows) - 1) print(tab.get_string())
The text was updated successfully, but these errors were encountered:
Looking the source code, the solution is:
import prettytable tab = prettytable.PrettyTable() for s in ["a", "b", "c"]: tab.add_row([s, s]) #tab.add_divider() if len(tab._dividers) > 0: tab._dividers[-1] = True for s in ["1", "2", "3"]: tab.add_row([s, s]) print(tab.get_string())
Be aware that if code changes, this can break.
Sorry, something went wrong.
No branches or pull requests
Is your feature request related to a problem? Please describe.
I would like to avoid detecting the last item of a loop to add a divider.
Therefore I would like to be able to set it separately, see example.
Describe the solution you'd like
Describe alternatives you've considered
Additional context
The text was updated successfully, but these errors were encountered: