Why does not pprint work?

emile emile at fenx.com
Wed Jul 23 00:17:49 CEST 2014


On 07/22/2014 03:05 PM, fl wrote:
> On Tuesday, July 22, 2014 5:51:07 PM UTC-4, emile wrote:
>> On 07/22/2014 02:42 PM, fl wrote:
>> pprint is a module name -- you need to invoke the pprint function from
>> within the pprint module:
>> pprint.pprint(board)
>
> Thanks. I am curious about the two pprint. Is it the first pprint the name of the
> module? The second pprint is the function name?

Yes.


> Then, how can I list all the function of pprint?

use the dir builtin:

 >>> dir (pprint)
['PrettyPrinter', '_StringIO', '__all__', '__builtins__', '__doc__', 
'__file__', '__name__', '_commajoin', '_id', '_len', '_perfcheck', 
'_recursion', '_safe_repr', '_sys', '_type', 'isreadable', 
'isrecursive', 'pformat', 'pprint', 'saferepr']


>
> And, is there a way to list the variables I create in Python?

also dir:

 >>> dir()
['__builtins__', '__doc__', '__name__', 'board', 'mylist', 'pprint', 
'reassign']


Emile





More information about the Python-list mailing list