Website hosting service by Active-Venture.com
  

 Back to Index


3.25.1 PrettyPrinter Objects

PrettyPrinter instances have the following methods:

 

 
pformat( object)
Return the formatted representation of object. This takes into Account the options passed to the PrettyPrinter constructor.

 

 
pprint( object)
Print the formatted representation of object on the configured stream, followed by a newline.

The following methods provide the implementations for the corresponding functions of the same names. Using these methods on an instance is slightly more efficient since new PrettyPrinter objects don't need to be created.

 

 
isreadable( object)
Determine if the formatted representation of the object is ``readable,'' or can be used to reconstruct the value using eval() . Note that this returns false for recursive objects. If the depth parameter of the PrettyPrinter is set and the object is deeper than allowed, this returns false.

 

 
isrecursive( object)
Determine if the object requires a recursive representation.

This method is provided as a hook to allow subclasses to modify the way objects are converted to strings. The default implementation uses the internals of the saferepr() implementation.

 

 
format( object, context, maxlevels, level)
Returns three values: the formatted version of object as a string, a flag indicating whether the result is readable, and a flag indicating whether recursion was detected. The first argument is the object to be presented. The second is a dictionary which contains the id() of objects that are part of the current presentation context (direct and indirect containers for object that are affecting the presentation) as the keys; if an object needs to be presented which is already represented in context, the third return value should be true. Recursive calls to the format() method should add additionaly entries for containers to this dictionary. The fourth argument, maxlevels, gives the requested limit to recursion; this will be 0 if there is no requested limit. This argument should be passed unmodified to recursive calls. The fourth argument, level gives the current level; recursive calls should be passed a value less than that of the current call. New in version 2.3.

  

 

2002-2004 Active-Venture.com Webhosting Service

 

Disclaimer: This documentation is provided only for the benefits of our hosting customers.
For authoritative source of the documentation, please refer to http://python.org/doc/

 

Active-Domain.com offers domain name registration, domain name transfer and domain search services  

Cheap domain registration : Register domain name or buy domain name, including free domain hosting services

 
 

Domain registration : Buy domain name or register domain name from $5.95/year only