[New-bugs-announce] [issue6743] pprint.pprint should support no objects to print blank lines & allow args

Mary Stern report at bugs.python.org
Thu Aug 20 16:21:06 CEST 2009


New submission from Mary Stern <marystern at yahoo.com>:

Using print in python 3 I would like to simple "replace" print with
pprint.pprint. However pprint cannot be called with no arguments, so
this cannot currently be done (the error is "TypeError: pprint() takes
at least 1 positional argument (0 given)").

A simple improvement is to allow no object to be passed in and pprint
would then print a newline rather than fail.

Another problem is that if you try this:

 print('hello', True)

and replace print with print, the second arg gets interpreted as the
"stream" parameter.


Both of the above can be fixed (I think) by changing pprint.py as follows:

instead of the current code:
def pprint(object, stream=None, indent=1, width=80, depth=None):

change to this:
def pprint(object='\n', *args, stream=None, indent=1, width=80, depth=None)

----------
messages: 91774
nosy: marystern
severity: normal
status: open
title: pprint.pprint should support no objects to print blank lines & allow args
type: feature request
versions: Python 3.1

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6743>
_______________________________________


More information about the New-bugs-announce mailing list