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


Groups > comp.lang.python > #75033

Re: Why does not pprint work?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!weretis.net!feeder4.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!xlned.com!feeder7.xlned.com!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.005
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'subject:not': 0.03; 'correct.': 0.07; 'variables': 0.07; '22,': 0.09; 'name?': 0.09; 'subject:Why': 0.09; 'cc:addr:python-list': 0.11; '23,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'globals(),': 0.16; 'make,': 0.16; 'module?': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'module': 0.19; 'thanks.': 0.20; '>>>': 0.22; 'import': 0.22; 'python?': 0.22; 'cc:addr:python.org': 0.22; 'math': 0.24; 'cc:2**0': 0.24; 'this:': 0.26; 'second': 0.26; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'invoke': 0.31; 'could': 0.34; 'case,': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'curious': 0.36; "didn't": 0.36; 'subject:?': 0.36; 'two': 0.37; 'list': 0.37; 'pm,': 0.38; 'skip:p 20': 0.39; 'how': 0.40; 'then,': 0.60; 'first': 0.61; 'name': 0.63; 'july': 0.63; 'within': 0.65; 'jul': 0.74; 'kinda.': 0.84; 'start.': 0.84; 'to:none': 0.92
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=ZQ8ijAajhincPQZHjQBEVGb0KrvKTTkmr95qEZ0LDR4=; b=dGZga7AS9BBBOpwlwc2F+M+2qEz5k1xYztrnP86l+DoKf/7SRohSuUoe7e725LvoJT Xciq1C7D2t48E4JCwlmUtVl1KMswO73v7mj2TjEHAi6r5nrgqb9WbrI6faaGRx4lkfCm YJJSy1uZ2ouFFOP1wdMHulHGR5GsPrAd/ZqkmxBMB376bd5DBHtqQL7slUgOsbnKenDx vVo7JYv2PIW6pbGnojud0RMcNY26szF/2EjrsqC92WmiN8W01j5mojMSgou00aAkLE1Z /wPdpDS3seriY4FbDQqFxbU4HhPOmoW+d78uHH7QCjzxmOXZEEYbYZNXz90NiawlfDpT LLzA==
MIME-Version 1.0
X-Received by 10.52.138.209 with SMTP id qs17mr16833234vdb.80.1406067585201; Tue, 22 Jul 2014 15:19:45 -0700 (PDT)
In-Reply-To <d7e3d1fa-29d3-4408-acb0-a85f96e57c0a@googlegroups.com>
References <6e09bc9c-d510-4076-b20d-32df796ca59e@googlegroups.com> <mailman.12199.1406065896.18130.python-list@python.org> <d7e3d1fa-29d3-4408-acb0-a85f96e57c0a@googlegroups.com>
Date Wed, 23 Jul 2014 08:19:45 +1000
Subject Re: Why does not pprint work?
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.12201.1406067587.18130.python-list@python.org> (permalink)
Lines 39
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1406067587 news.xs4all.nl 2957 [2001:888:2000:d::a6]:51826
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:75033

Show key headers only | View raw


On Wed, Jul 23, 2014 at 8:05 AM, fl <rxjwg98@gmail.com> 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?

Correct. There's a module pprint which provides a function
pprint.pprint. It's like you can do this:
>>> import math
>>> math.sin(3.14/2)
0.9999996829318346

Or this:
>>> from math import sin
>>> sin(3.14/2)
0.9999996829318346

It's just that in this case, "math" and "sin" are both "pprint".

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

>>> import pprint
>>> help(pprint)

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

Kinda. Try this:

>>> dir()

There'll be some in there that you didn't make, but that's a start.
You could also try vars() or globals(), which will give you their
values as well.

ChrisA

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