Date: 22 Aug 2022
Module : prettyprinter Installation : pip install prettyprinter About: Write pretty printers for your standard type list, dict, etc and own types with a dead simple, declarative interface. Sample Code: from datetime import datetime from prettyprinter import pprint, register_pretty, pretty_call class MyClass: def __init__(self, one, two): self.one = one self.two = two @register_pretty(MyClass) def pretty_myclass(value, ctx): return pretty_call(ctx, MyClass, one=value.one, two=value.two) ## print the output of the date in pretty format pprint({'beautiful output': datetime.now()}) ## print class object in pretty format pprint({'beautiful MyClass instance': MyClass((1, 2, 3), {'a': 1, 'b': 2})}) Output: % python pprint_sample.py { 'beautiful output': datetime.datetime( year=2022, month=8, day=22, hour=23, minute=26, second=40, microsecond=188629 ) } { 'beautiful MyClass instance': MyClass( one=(1, 2, 3), two={'a': 1, 'b': 2} ) } Reference: https://pypi.org/project/prettyprinter/
_______________________________________________ Chennaipy mailing list Chennaipy@python.org https://mail.python.org/mailman/listinfo/chennaipy