[issue36705] Unexpected Behaviour of pprint.pprint

2019-04-23 Thread Fred L. Drake, Jr.


Fred L. Drake, Jr.  added the comment:

Eric nailed it; pprint was not designed as a replacement for print, and was 
never intended to serve that purpose.

Rejecting as out of scope.

--
resolution:  -> rejected
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36705] Unexpected Behaviour of pprint.pprint

2019-04-23 Thread Eric V. Smith


Eric V. Smith  added the comment:

pprint.pprint is not designed to be a drop-in replacement for print. At this 
point, we cannot break existing code to change how pprint works.

I suggest you make a pprint.pprint wrapper that does what you want, or maybe 
subclass pprint.PrettyPrinter.

--
nosy: +eric.smith

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36705] Unexpected Behaviour of pprint.pprint

2019-04-23 Thread Gavin D'souza


Gavin D'souza  added the comment:

if pprint is called without parameters, it returns a TypeError

>>> pprint()
Traceback (most recent call last):
  File "", line 1, in 
TypeError: pprint() missing 1 required positional argument: 'object'

it would be beneficial however to return an empty string or a new line 
character instead. An erroneous call would generate an unnecessary run-time 
error in a huge script

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36705] Unexpected Behaviour of pprint.pprint

2019-04-23 Thread Gavin D'souza


New submission from Gavin D'souza :

For a simple string input, pprint would be expected to return an output similar 
to print. However, the functionality differs

### Code:
import time
from pprint import pprint

start = time.time()
time.sleep(0.5)
object_made = time.time()
time.sleep(0.5)
done = time.time()
time.sleep(0.5)
shown = time.time()

pprint(
f"Time to create object: {object_made - start}s\n" +
f"Time to insert 10 rows: {done - object_made}s\n" +
f"Time to retrieve 10 rows: {shown - done}s\n"
)

### Output Received:
('Time to create object: 0.5010814666748047s\n'
 'Time to insert 10 rows: 0.5010972023010254s\n'
 'Time to retrieve 10 rows: 0.501101016998291s\n')

### Expected Output:
Time to create object: 0.5010814666748047s
Time to insert 10 rows: 0.5010972023010254s
Time to retrieve 10 rows: 0.501101016998291s

--
components: Library (Lib)
messages: 340720
nosy: Gavin D'souza, fdrake
priority: normal
severity: normal
status: open
title: Unexpected Behaviour of pprint.pprint
type: behavior
versions: Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com