Login

Tag "tableize"

Snippet List

format output as table

Ever wished you could have pretty SQL-like output for a python object (e.g., a list of dicts) while you're debugging your code? This function will do just that. Simply pass it an object that is an iterable of dictionaries and it returns it in an easy-to-read table, similar to the output of commandline SQL. Example: from tablelize import tableize from django.contrib.auth.models import User print(tableize(User.objects.values('email', 'first_name', 'last_name'))) +------------+-----------+-------------------+ | first_name | last_name | email | +------------+-----------+-------------------+ | Test | User | [email protected] | | Another | User | [email protected] | +------------+-----------+-------------------+

  • format
  • table
  • output
  • tablize
  • tableize
Read More

1 snippet posted so far.