gpt-4-0613· OpenAI
Arena Human Preference 55K
write python code that provides a pretty cli interface
- User
write python code that provides a pretty cli interface
- Assistant
Here is a simple pretty CLI interface in Python using
richlibrary. Rich library is a Python library for rich text and beautiful formatting in the terminal.Rich can also render pretty tables, progress bars, syntax highlighted code, markdown, and more out of the box.
from rich.console import Console from rich.table import Table # Create a Console instance console = Console() def create_table(): table = Table(show_header=True, header_style="bold magenta") table.add_column("Name", style="dim", width=12) table.add_column("Age") table.add_column("City") return table def add_data_to_table(table): table.add_row("John", "24", "New York") table.add_row("Linda", "29", "Los Angeles") table.add_row("Tom", "35", "Chicago") return table def main(): console.print("Hello, this is a pretty CLI interface!", style="bold red") table = create_table() table = add_data_to_table(table) console.print(table) if __name__ == "__main__": main()
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.