{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {
    "Notes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Warns": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Raises": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Yields": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Methods": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Returns": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "No Docstrings"
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Receives": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Warnings": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Attributes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Parameters": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Extended Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Other Parameters": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    }
  },
  "_ordered_sections": [
    "Summary",
    "Extended Summary",
    "Parameters",
    "Attributes",
    "Methods",
    "Returns",
    "Yields",
    "Receives",
    "Other Parameters",
    "Raises",
    "Warns",
    "Warnings",
    "Notes"
  ],
  "item_file": "/IPython/lib/pretty.py",
  "item_line": 0,
  "item_type": "module",
  "aliases": [
    "IPython.lib.pretty"
  ],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [],
  "signature": null,
  "references": null,
  "qa": "IPython.lib.pretty",
  "arbitrary": [
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Python advanced pretty printer.  This pretty printer is intended to replace the old "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "pprint",
              "reference": {
                "__type": "RefInfo",
                "__tag": 4000,
                "module": "pprint",
                "version": "*",
                "kind": "api",
                "path": "pprint"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " python module which does not allow developers to provide their own pretty print callbacks."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "This module is based on ruby's "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "prettyprint.rb",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " library by "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "Tanaka Akira",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "To directly print the representation of an object use "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "pprint",
              "reference": {
                "__type": "RefInfo",
                "__tag": 4000,
                "module": "pprint",
                "version": "*",
                "kind": "api",
                "path": "pprint"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ":      "
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "from pretty import pprint\npprint(complex_object)",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "To get a string of the output use "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "pretty",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "module",
                "path": "IPython.lib.pretty"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ":      "
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "from pretty import pretty\nstring = pretty(complex_object)",
          "execution_status": null
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Example Usage"
        }
      ],
      "level": 0,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The pretty library allows developers to add pretty printing rules for their own objects.  This process is straightforward.  All you have to do is to add a "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "_repr_pretty_",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " method to your object and call the methods on the pretty printer passed      "
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "class MyObject(object):\n\n    def _repr_pretty_(self, p, cycle):\n        ...",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Here's an example for a class with a simple constructor      "
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "class MySimpleObject:\n\n    def __init__(self, a, b, *, c=None):\n        self.a = a\n        self.b = b\n        self.c = c\n\n    def _repr_pretty_(self, p, cycle):\n        ctor = CallExpression.factory(self.__class__.__name__)\n        if self.c is None:\n            p.pretty(ctor(a, b))\n        else:\n            p.pretty(ctor(a, b, c=c))",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Here is an example implementation of a "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "_repr_pretty_",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " method for a list subclass      "
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "class MyList(list):\n\n    def _repr_pretty_(self, p, cycle):\n        if cycle:\n            p.text('MyList(...)')\n        else:\n            with p.group(8, 'MyList([', '])'):\n                for idx, item in enumerate(self):\n                    if idx:\n                        p.text(',')\n                        p.breakable()\n                    p.pretty(item)",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "cycle",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " parameter is "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "True",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " if pretty detected a cycle.  You "
            },
            {
              "__type": "Emphasis",
              "__tag": 4047,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "have"
                }
              ]
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " to react to that or the result is an infinite loop.  "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "p.text()",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " just adds non breaking text to the output, "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "p.breakable()",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " either adds a whitespace or breaks here.  If you pass it an argument it's used instead of the default space.  "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "p.pretty",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " prettyprints another object using the pretty print method."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The first parameter to the "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "group",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " function specifies the extra indentation of the next line.  In this example the next item will either be on the same line (if the items are short enough) or aligned with the right edge of the opening bracket of "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "MyList",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "If you just want to indent something you can use the group function without open / close parameters.  You can also use this code      "
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "with p.indent(2):\n    ...",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Inheritance diagram:"
            }
          ]
        },
        {
          "__type": "FieldList",
          "__tag": 4035,
          "children": [
            {
              "__type": "FieldListItem",
              "__tag": 4036,
              "name": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "copyright"
                }
              ],
              "body": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "2007 by Armin Ronacher.             Portions (c) 2009 by Robert Kern."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "FieldListItem",
              "__tag": 4036,
              "name": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "license"
                }
              ],
              "body": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "BSD License."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Extending"
        }
      ],
      "level": 0,
      "target": null
    }
  ],
  "local_refs": []
}