Why does not pprint work?

emile emile at fenx.com
Tue Jul 22 17:51:07 EDT 2014


On 07/22/2014 02:42 PM, fl wrote:
> Hi,
>
> I read web tutorial at:
>
> http://nedbatchelder.com/blog/201308/names_and_values_making_a_game_board.html
>
> I enter the example lines of that website:
>
>
> import pprint
> board = [ [0]*8 ] * 8
> pprint(board)
>
>

pprint is a module name -- you need to invoke the pprint function from 
within the pprint module:

pprint.pprint(board)

or alternately,

from pprint import pprint

pprint(board)


or, as I sometime do

from pprint import pprint as pp

pp(board)



Emile





More information about the Python-list mailing list