Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

A woman should have compassion. -- Kirk, "Catspaw", stardate 3018.2


devel / comp.lang.python / Re: Function to Print a nicely formatted Dictionary or List?

SubjectAuthor
* Re: Function to Print a nicely formatted Dictionary or List?Chris Angelico
`* Re: Function to Print a nicely formatted Dictionary or List?Michael F. Stemper
 `- Re: Function to Print a nicely formatted Dictionary or List?Dan Stromberg

1
Re: Function to Print a nicely formatted Dictionary or List?

<mailman.600.1654797135.20749.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=18558&group=comp.lang.python#18558

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!fu-berlin.de!uni-berlin.de!not-for-mail
From: ros...@gmail.com (Chris Angelico)
Newsgroups: comp.lang.python
Subject: Re: Function to Print a nicely formatted Dictionary or List?
Date: Fri, 10 Jun 2022 03:52:02 +1000
Lines: 15
Message-ID: <mailman.600.1654797135.20749.python-list@python.org>
References: <6C7CEF1D-A810-44E0-8A23-6B34916C308D@looktowindward.com>
<CAPTjJmogFndKX5bUXB3vS7VyN9KDeBtZoE97gqcnFJM5Ay6+MA@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de 8Ntvy6Lk/z7GdbCq9e4G9wAp7UreQTHerv7/ybJMPMiQ==
Return-Path: <rosuav@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=TrgeLsvW;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.004
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'knows': 0.04; '2022':
0.05; 'cc:addr:python-list': 0.09; 'cc:no real name:2**0': 0.14;
'import': 0.15; 'chrisa': 0.16; 'from:addr:rosuav': 0.16;
'from:name:chris angelico': 0.16; 'wrote:': 0.16;
'cc:addr:python.org': 0.20; 'fri,': 0.22; 'cc:2**0': 0.25;
'anyone': 0.25; 'jun': 0.26; 'function': 0.27; 'wondering': 0.31;
'message-id:@mail.gmail.com': 0.32; 'mean': 0.34; 'header:In-
Reply-To:1': 0.34; 'received:google.com': 0.34;
'from:addr:gmail.com': 0.35; 'received:209.85': 0.37;
'received:209': 0.39; 'subject:List': 0.71
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=mime-version:references:in-reply-to:from:date:message-id:subject:to
:cc; bh=cPPHufue6GVHeDUdn0LPrQZgFQKu7K9Wu8aDhnCAjr0=;
b=TrgeLsvWy1qu4s9Cxjz96vQVg4pJTP5MO3e1ryvjKBc502jHgo+B7hbnrt3lC4Nxsu
sTERE/MmFy+MBro/tmnzq3DFEGLL2oPqrb5CGe5X9UD7mO0jYE9Ra+MQvyIreo1lt50P
X/pr01YGYD9ciXOLSgV6FCFf2ROT+RIvmWO1ahi1TC4thz+FqUE/o2bZDFiUGri1xuhX
v8Ed+DwV6OJji0ZVcj68yYprkGUUCEik8Pdpkrt0gGGf8VGH1Tk/u5AoYmKJqb3PsRCo
6WTtK8uK8/9W4tmLjaa+fs1UKKVDdIL9SiEEos70Dvw3KQE0LsKLrZniGKwNEPCiFemZ
0z7w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to:cc;
bh=cPPHufue6GVHeDUdn0LPrQZgFQKu7K9Wu8aDhnCAjr0=;
b=fR76ylzFcvCVtkBkpbudFHww6TV94W5MBVzG4ecFWdfJ7XSE09T8db7bgsgDFWvBsl
0Ls7FFBj3EDTvMjaFRxTCHPGQwrV7x2HC0qZV92q2tYyXivwYoQejRjRlC0YuXzKR5lg
YFuUdeynwBjN5jRm0PP9QSrnLOf+33FOP9SgqKFRXbw4qwJoZzwvVY+iFF36Z/p320II
T1SC8VI42IGNHWvf3dIauCj/yvjau7Z0HcDybvMK8PwX849dVyxvk/YTSYezr8G7Nd03
EyPJZYO4WpsagX19PdxiEo0LzgzCnZqTa3xWPDgwF+WH1h6gjbWnqF8XTbfbX1dUGhgj
JuNw==
X-Gm-Message-State: AOAM531jhBuse0LMaaI2R0hcpgwB05xOtMOISeaNi3pCAH0QjGB3dsIW
vVrW1OjIdY3g44CPvzdzBibTkQMgW5zUWKLzyDUtRY1rUtw=
X-Google-Smtp-Source: ABdhPJxwAQC4DlzkTTGlwz6mBHUjHaP0yBIeIOwwkCsKnKmtffIs1y9cmiwfeu5JgCWyOANXqqbBPq9n1iX2m+umgFw=
X-Received: by 2002:adf:ae09:0:b0:20e:e4f0:2133 with SMTP id
x9-20020adfae09000000b0020ee4f02133mr39954131wrc.104.1654797133340; Thu, 09
Jun 2022 10:52:13 -0700 (PDT)
In-Reply-To: <6C7CEF1D-A810-44E0-8A23-6B34916C308D@looktowindward.com>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
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: <https://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>
X-Mailman-Original-Message-ID: <CAPTjJmogFndKX5bUXB3vS7VyN9KDeBtZoE97gqcnFJM5Ay6+MA@mail.gmail.com>
X-Mailman-Original-References: <6C7CEF1D-A810-44E0-8A23-6B34916C308D@looktowindward.com>
 by: Chris Angelico - Thu, 9 Jun 2022 17:52 UTC

On Fri, 10 Jun 2022 at 03:44, Dave <dave@looktowindward.com> wrote:
>
> Hi,
>
> Before I write my own I wondering if anyone knows of a function that will print a nicely formatted dictionary?
>
> By nicely formatted I mean not all on one line!
>

https://docs.python.org/3/library/pprint.html

from pprint import pprint
pprint(thing)

ChrisA

Re: Function to Print a nicely formatted Dictionary or List?

<t7tisg$ne0$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=18567&group=comp.lang.python#18567

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: michael....@gmail.com (Michael F. Stemper)
Newsgroups: comp.lang.python
Subject: Re: Function to Print a nicely formatted Dictionary or List?
Date: Thu, 9 Jun 2022 14:49:36 -0500
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <t7tisg$ne0$2@dont-email.me>
References: <6C7CEF1D-A810-44E0-8A23-6B34916C308D@looktowindward.com>
<CAPTjJmogFndKX5bUXB3vS7VyN9KDeBtZoE97gqcnFJM5Ay6+MA@mail.gmail.com>
<mailman.600.1654797135.20749.python-list@python.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 9 Jun 2022 19:49:36 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="218f0825ff5f68bd5d31e62241e54930";
logging-data="24000"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19C7zcLgVbaKHCDLJZMDtLuaepCjmEI/tQ="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
Thunderbird/68.10.0
Cancel-Lock: sha1:ubDhc99gPlw9pqVG79f+OAr68b8=
In-Reply-To: <mailman.600.1654797135.20749.python-list@python.org>
Content-Language: en-US
 by: Michael F. Stemper - Thu, 9 Jun 2022 19:49 UTC

On 09/06/2022 12.52, Chris Angelico wrote:
> On Fri, 10 Jun 2022 at 03:44, Dave <dave@looktowindward.com> wrote:

>> Before I write my own I wondering if anyone knows of a function that will print a nicely formatted dictionary?
>>
>> By nicely formatted I mean not all on one line!
>>
>
> https://docs.python.org/3/library/pprint.html
>
> from pprint import pprint
> pprint(thing)

>>> from pprint import pprint
>>> d = {'two':2, 'three':5}
>>> pprint(d)
{'three': 5, 'two': 2}
>>>

This is all on one line. That might be acceptable to the OP, but it
doesn't actually match what he said.

--
Michael F. Stemper
Outside of a dog, a book is man's best friend.
Inside of a dog, it's too dark to read.

Re: Function to Print a nicely formatted Dictionary or List?

<mailman.608.1654822756.20749.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=18572&group=comp.lang.python#18572

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: drsali...@gmail.com (Dan Stromberg)
Newsgroups: comp.lang.python
Subject: Re: Function to Print a nicely formatted Dictionary or List?
Date: Thu, 9 Jun 2022 17:59:02 -0700
Lines: 30
Message-ID: <mailman.608.1654822756.20749.python-list@python.org>
References: <6C7CEF1D-A810-44E0-8A23-6B34916C308D@looktowindward.com>
<CAPTjJmogFndKX5bUXB3vS7VyN9KDeBtZoE97gqcnFJM5Ay6+MA@mail.gmail.com>
<mailman.600.1654797135.20749.python-list@python.org>
<t7tisg$ne0$2@dont-email.me>
<CAGGBd_oe+raFJX7wvb_HLmZ7Zmo7yj4Tyo_3c-SVU8pW+Q8=uQ@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de uJmyZrBmL4/ZgJKRrf9c4gpC0MIpe46UxhRbLYZfY46Q==
Return-Path: <drsalists@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=EG5+SwvU;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.005
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'knows': 0.04; '2022':
0.05; '&gt;&gt;&gt;': 0.07; 'angelico': 0.09; 'cc:addr:python-
list': 0.09; '&gt;': 0.14; 'import': 0.15; 'cc:name:python list':
0.16; 'from:addr:drsalists': 0.16; 'from:name:dan stromberg':
0.16; 'wrote:': 0.16; 'larger': 0.17; 'uses': 0.19; 'thu,': 0.19;
'cc:addr:python.org': 0.20; 'fri,': 0.22; 'cc:2**0': 0.25;
'anyone': 0.25; 'jun': 0.26; 'function': 0.27; '>>>': 0.28;
'chris': 0.28; 'wondering': 0.31; "doesn't": 0.32; 'message-
id:@mail.gmail.com': 0.32; 'but': 0.32; 'mean': 0.34; 'header:In-
Reply-To:1': 0.34; 'received:google.com': 0.34;
'received:209.85.166': 0.35; 'from:addr:gmail.com': 0.35; "it's":
0.37; 'received:209.85': 0.37; 'received:209': 0.39; 'single':
0.39; 'match': 0.40; 'michael': 0.60; 'skip:h 10': 0.61;
'acceptable': 0.69; 'subject:List': 0.71; 'said.': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=mime-version:references:in-reply-to:from:date:message-id:subject:to
:cc; bh=NdmmjODKWV+s4O/iETGkKR5wS1je9fbcoJuwPk+v4GU=;
b=EG5+SwvU7y48wMFLWt6YQrdMJCIOt9CuUBg027Hfer0TSURFSphRX0SQhushCrl05W
78qKhCLqz11VFm2fT0/GYHVXfEpnmehLYzgO26NyaHbWA4AB0Nf4UX7gxoxvgxlBdl2m
RSrOkPQ/O4dtVGleotlUIiMHEmvD4IWMEcXWa3Dt2j3LqpNrcAQXY7q782NIwRGbrPJT
sIMsH3x+EhukOm1391Zy4hym9Sn7Oln1q2ECNFT3eNI7qy5nSoU9ZyoC98u29iel9FYv
iyrAXXXAmA+jbYetIYGjISUMa91ID3t0TRusmugR86eImd2vKL2LiMjRuR9w0AAN9cPV
TvoQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to:cc;
bh=NdmmjODKWV+s4O/iETGkKR5wS1je9fbcoJuwPk+v4GU=;
b=0KWkdYLnA0m1N1kSN7JZBe/lWDwyRKHHmMrCBGGV4GOCENYFkJGy8ZF8bymQGO+FFS
VWQD83zJtneRiAqDnYgEhfPKz/9M1SAQGWl5aY2YMTYoqXocIWFVeYfqm5lLFG9Rmy1S
z/egNn+6qqLIKLdvwaVCF5muIrPbnCeExdYeiEOvpdhp4mhExhsaLechrJoa80XbTh9Y
SZdAggtGmJ0mH1gclQuRO1kgqoU/7yutthtLgarnir7EAD4s8AsYXBGAK9/wse4Z+tZC
5q5M3nO5YdCj/KexNDGpFjBgm3XF4+lduTLGiI1Q6fw6z6tFadqEnefAmJssl0lRkFZ0
Y67w==
X-Gm-Message-State: AOAM532Fs7cIuoKbkkvLhI+4d2sLNE65QiJJAmTf91qJCF7bWeG3alrt
tAeh6jrlJuYk4wJFfIIRaQmxINRoj6i8Md9AMc4=
X-Google-Smtp-Source: ABdhPJyxMTaMKdN4Xld2BiaHBTIY+jDguLnVwDBctS0DH1YHqXuitKvgvgk7LxIwjvP2Dnvg70zrQcE58wOYTIJy/bI=
X-Received: by 2002:a05:6e02:17c7:b0:2d3:c741:e1eb with SMTP id
z7-20020a056e0217c700b002d3c741e1ebmr25177098ilu.87.1654822753537; Thu, 09
Jun 2022 17:59:13 -0700 (PDT)
In-Reply-To: <t7tisg$ne0$2@dont-email.me>
X-Content-Filtered-By: Mailman/MimeDel 2.1.39
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
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: <https://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>
X-Mailman-Original-Message-ID: <CAGGBd_oe+raFJX7wvb_HLmZ7Zmo7yj4Tyo_3c-SVU8pW+Q8=uQ@mail.gmail.com>
X-Mailman-Original-References: <6C7CEF1D-A810-44E0-8A23-6B34916C308D@looktowindward.com>
<CAPTjJmogFndKX5bUXB3vS7VyN9KDeBtZoE97gqcnFJM5Ay6+MA@mail.gmail.com>
<mailman.600.1654797135.20749.python-list@python.org>
<t7tisg$ne0$2@dont-email.me>
 by: Dan Stromberg - Fri, 10 Jun 2022 00:59 UTC

On Thu, Jun 9, 2022 at 1:52 PM Michael F. Stemper <michael.stemper@gmail.com>
wrote:

> On 09/06/2022 12.52, Chris Angelico wrote:
> > On Fri, 10 Jun 2022 at 03:44, Dave <dave@looktowindward.com> wrote:
>
> >> Before I write my own I wondering if anyone knows of a function that
> will print a nicely formatted dictionary?
> >>
> >> By nicely formatted I mean not all on one line!
> >>
> >
> > https://docs.python.org/3/library/pprint.html
> >
> > from pprint import pprint
> > pprint(thing)
>
> >>> from pprint import pprint
> >>> d = {'two':2, 'three':5}
> >>> pprint(d)
> {'three': 5, 'two': 2}
> >>>
>
> This is all on one line. That might be acceptable to the OP, but it
> doesn't actually match what he said.
>

For small outputs, pprint uses a single line. For larger outputs, it
inserts newlines. It's intended to be human-readable more than
machine-readable.

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor