Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #75621

Re: Why does not pprint work?

Newsgroups comp.lang.python
Date 2014-08-03 14:34 -0700
References <6e09bc9c-d510-4076-b20d-32df796ca59e@googlegroups.com>
Message-ID <71cc5e7f-9933-4702-b2ac-b0fab6e0457e@googlegroups.com> (permalink)
Subject Re: Why does not pprint work?
From robkotenko@gmail.com

Show all headers | View raw


With the way you have imported, you trying to use the module pprint instead of the function pprint.pprint.  

You need to use pprint.pprint or you need to import as:

from pprint import pprint

if you want to use the shorter form.

On Tuesday, July 22, 2014 5:42:02 PM UTC-4, 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)
> 
> 
> 
> 
> 
> It echos error with Python 2.7:
> 
> 
> 
> Traceback (most recent call last):
> 
>   File "C:\Python27\Lib\SITE-P~1\PYTHON~2\pywin\framework\scriptutils.py", 
> 
> line 323, in RunScript
> 
>     debugger.run(codeObject, __main__.__dict__, start_stepping=0)
> 
>   File "C:\Python27\Lib\SITE-P~1\PYTHON~2\pywin\debugger\__init__.py", 
> 
> line 60, in run
> 
>     _GetCurrentDebugger().run(cmd, globals,locals, start_stepping)
> 
>   File "C:\Python27\Lib\SITE-P~1\PYTHON~2\pywin\debugger\debugger.py", 
> 
> line 655, in run
> 
>     exec cmd in globals, locals
> 
>   File "C:\cygwin64\home\Jeff\Python_lesson\ppn.py", line 1, in <module>
> 
>     import pprint
> 
> TypeError: 'module' object is not callable
> 
> 
> 
> It has similar error with Python 3.4.1.
> 
> 
> 
> 
> 
> Why does pprint not work?
> 
> 
> 
> 
> 
> Thanks,

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Why does not pprint work? fl <rxjwg98@gmail.com> - 2014-07-22 14:42 -0700
  Re: Why does not pprint work? Chris Angelico <rosuav@gmail.com> - 2014-07-23 07:49 +1000
  Re: Why does not pprint work? emile <emile@fenx.com> - 2014-07-22 14:51 -0700
    Re: Why does not pprint work? fl <rxjwg98@gmail.com> - 2014-07-22 15:05 -0700
      Re: Why does not pprint work? emile <emile@fenx.com> - 2014-07-22 15:17 -0700
      Re: Why does not pprint work? Chris Angelico <rosuav@gmail.com> - 2014-07-23 08:19 +1000
      Re: Why does not pprint work? Chris Kaynor <ckaynor@zindagigames.com> - 2014-07-22 15:22 -0700
  Re: Why does not pprint work? Ned Batchelder <ned@nedbatchelder.com> - 2014-07-22 22:26 -0400
  Re: Why does not pprint work? Chris Angelico <rosuav@gmail.com> - 2014-07-23 15:05 +1000
  Re: Why does not pprint work? robkotenko@gmail.com - 2014-08-03 14:34 -0700
    Re: Why does not pprint work? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-08-03 23:49 +0100

csiph-web