Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python: Module Error with pprint, no error with print

So I have this function that creates a dictionary called a() and takes parameters params. I want to print that dictionary, so I used pprint:

dict=a(params)
pprint(dict)

pprint gives me this error:

TypeError: 'module' object is not callable

but print works fine!

like image 370
JOHANNES_NYÅTT Avatar asked Jan 14 '13 01:01

JOHANNES_NYÅTT


Video Answer


1 Answers

How did you import pprint? If you didn't specify what to import from pprint you need to use the module name when calling.

import pprint
pprint.pprint(...)

Or you can import a specific method.

from pprint import pprint
pprint(...)
like image 124
Tim Avatar answered Nov 07 '22 18:11

Tim