pprint Filter

Coding

Documentation

Pretty prints a Python object using pprint.pprint wrapper.

Variable

context['classes'] = {
    'Python': [
        'Introduction to Python Training', 'Advanced Python Training',
        'Data Science Training', 'Django Training'
    ],
    'Databases': [
        'Introduction to PostgreSQL Training', 'Introduction to MySQL Training', 
        'Introduction to SQL Server Training', 'Introduction to Oracle Training'
    ],
    'Web': [
        'HTML Training', 'CSS Training', 'JavaScript Training'
    ],
    'XML': [
        'Introduction to XML Training'
    ]
}

Template

<pre>{{ classes|pprint }}</pre>

Result

{'Databases': ['Introduction to PostgreSQL Training',
               'Introduction to MySQL Training',
               'Introduction to SQL Server Training',
               'Introduction to Oracle Training'],
 'Python': ['Introduction to Python Training',
            'Advanced Python Training',
            'Data Science Training',
            'Django Training'],
 'Web': ['HTML Training', 'CSS Training', 'JavaScript Training'],
 'XML': ['Introduction to XML Training']}

Commentary

Could be useful for debugging, though you can do the same thing at the console.


Did we get something wrong? Is there a use case for the pprint filter that we should add? Please let us know.

Send Feedback

Official Documentation
This page last updated on Oct. 30, 2022, 1:21 p.m. EST