Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

The value of a program is proportional to the weight of its output.


devel / comp.lang.python / Printing Unicode strings in a list

SubjectAuthor
* Printing Unicode strings in a listStephen Tucker
`- Re: Printing Unicode strings in a listJon Ribbens

1
Printing Unicode strings in a list

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

 copy mid

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

 copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: stephen_...@sil.org (Stephen Tucker)
Newsgroups: comp.lang.python
Subject: Printing Unicode strings in a list
Date: Thu, 28 Apr 2022 12:32:22 +0100
Lines: 39
Message-ID: <mailman.269.1651145556.20749.python-list@python.org>
References: <CAP=-cKXWHH8f+479sn5c=KzYV=_gEu+9UZ+kFk5at-KiDFjQJA@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de M79n+47VIkac2hQLcRmhWQBNH1sesyT23hO/x6M25Dkw==
Return-Path: <stephen_tucker@sil.org>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="1024-bit key; unprotected key"
header.d=sil.org header.i=@sil.org header.b=Aj1Ot7kf;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.004
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'skip:= 10': 0.05;
'&gt;&gt;&gt;': 0.07; 'members,': 0.07; 'string': 0.07; 'that?':
0.07; 'log:': 0.09; 'received:209.85.219': 0.09;
'subject:Unicode': 0.09; 'subject:list': 0.11; 'log': 0.12;
'(instead': 0.16; '3.x': 0.16; 'behaviour': 0.16; 'displayed':
0.16; 'pythonic': 0.16; 'respect?': 0.16; 'unicode': 0.16;
'python': 0.16; 'to:addr:python-list': 0.20; 'run': 0.23; 'bit':
0.27; '>>>': 0.28; 'course.': 0.32; 'to:name:python': 0.32;
'message-id:@mail.gmail.com': 0.32; 'there': 0.33; 'same': 0.34;
'printing': 0.34; 'received:google.com': 0.34; 'yes,': 0.35;
'following': 0.35; 'using': 0.37; 'received:209.85': 0.37; 'way':
0.38; 'thanks': 0.38; 'received:209': 0.39; 'single': 0.39;
'list': 0.39; 'still': 0.40; 'want': 0.40; 'should': 0.40;
'produce': 0.65; 'arising': 0.67; '2015,': 0.69; '8bit%:18': 0.69;
'reasons': 0.84; 'characters': 0.84; 'exhibit': 0.84; 'strings':
0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sil.org; s=google;
h=mime-version:from:date:message-id:subject:to;
bh=pd+zRierS9KZMv56ZlTn0zSTtggVxl6cFT8YGDFObyc=;
b=Aj1Ot7kfLyxom7gAyvmA0av+NLSE6TnZV6UlJMLFscu38DBHpRh6k4yVM/vN63TZlU
UwhKiudGAC8j3cG8DuXyoDVDb0VxKpnqyOEMNo3Cp/aIBaJ6KNa9ovoWZzjxWtXwWXEO
EsI3z3G1ZHrRJzmly6ufo+UmKYwCJx3XT58KU=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
bh=pd+zRierS9KZMv56ZlTn0zSTtggVxl6cFT8YGDFObyc=;
b=ScPbBHiULL1ltp4yAJgG6PEpj8ecAmvdpnhs9W2rDGjwUcys+pyNyjVcJ9ENg1pm6r
meU3eWVdt4NN3PzFE52ok1/d4z/R/cDBXR7vqKy/fKGWNrVJySpAHK0qg+M1+9NarvHE
j8KVduM5P+LqL1e7CjXkZ3uFGp7sN5QprvnF1wnK0dvgWXxRRwtNcftbPSJbhwZxYxMz
4fvEw+wxD4Oat4bI4vPQJJBGBCNS1rWHyPiPIE8TTeeTgAdYhX0FCt6qDsQrjxZdAkIj
NcKLHWUeQilM7m0gxWNKYViztl1TTJbY6mdlh0FuCjeOF/yaYAsbz/iqS4mOO8JYEHje
2tMQ==
X-Gm-Message-State: AOAM530UCUprt+/k60LXsdePezOV68ev1CucqhFEURd2lMAB4iAavfKg
s1WH1Mh59O6zI+bkI9w+rTZyq5QI2DrWtmD9gg9D1/IHK4e6UsWi
X-Google-Smtp-Source: ABdhPJzRlXC+6xCffhD5bCfCzFLYE/G7zeps0ZMIaD57iszEdRI35n7bLQrSUqivze38iBrZuvMqvqxeSkZhYygiR2M=
X-Received: by 2002:a25:7b87:0:b0:645:389f:3509 with SMTP id
w129-20020a257b87000000b00645389f3509mr29497033ybc.155.1651145554003; Thu, 28
Apr 2022 04:32:34 -0700 (PDT)
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: <CAP=-cKXWHH8f+479sn5c=KzYV=_gEu+9UZ+kFk5at-KiDFjQJA@mail.gmail.com>
 by: Stephen Tucker - Thu, 28 Apr 2022 11:32 UTC

Hi PythonList Members,

Consider the following log from a run of IDLE:

=================
Python 2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)]
on win32
Type "copyright", "credits" or "license()" for more information.
>>> print (u"\u2551")

>>> print ([u"\u2551"])
[u'\u2551']
>>>

=================
Yes, I am still using Python 2.x - I have good reasons for doing so and
will be moving to Python 3.x in due course.

I have the following questions arising from the log:

1. Why does the second print statement not produce [ ║] or ["║"] ?

2. Should the second print statement produce [ ║] or ["║"] ?

3. Given that I want to print a list of Unicode strings so that their
characters are displayed (instead of their Unicode codepoint definitions),
is there a more Pythonic way of doing it than concatenating them into a
single string and printing that?

4. Does Python 3.x exhibit the same behaviour as Python 2.x in this respect?

Thanks in anticipation.

Stephen Tucker.

Re: Printing Unicode strings in a list

<slrnt6l00o.478.jon+usenet@raven.unequivocal.eu>

 copy mid

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

 copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: jon+use...@unequivocal.eu (Jon Ribbens)
Newsgroups: comp.lang.python
Subject: Re: Printing Unicode strings in a list
Date: Thu, 28 Apr 2022 11:52:56 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 50
Message-ID: <slrnt6l00o.478.jon+usenet@raven.unequivocal.eu>
References: <CAP=-cKXWHH8f+479sn5c=KzYV=_gEu+9UZ+kFk5at-KiDFjQJA@mail.gmail.com>
<mailman.269.1651145556.20749.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 28 Apr 2022 11:52:56 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="db331d89b0061bb28d2514f0e42fb709";
logging-data="7416"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19BH6CbHZMbfKhIWd/k6bdmLZEASe0/BXQ="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:2gX2/k5dAHwGBIKJUMOaVnuR0zM=
 by: Jon Ribbens - Thu, 28 Apr 2022 11:52 UTC

On 2022-04-28, Stephen Tucker <stephen_tucker@sil.org> wrote:
> Hi PythonList Members,
>
> Consider the following log from a run of IDLE:
>
>==================
>
> Python 2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)]
> on win32
> Type "copyright", "credits" or "license()" for more information.
>>>> print (u"\u2551")
> ║
>>>> print ([u"\u2551"])
> [u'\u2551']
>>>>
>
>==================
>
> Yes, I am still using Python 2.x - I have good reasons for doing so and
> will be moving to Python 3.x in due course.
>
> I have the following questions arising from the log:
>
> 1. Why does the second print statement not produce [ ║] or ["║"] ?

print(x) implicitly calls str(x) to convert 'x' to a string for output.
lists don't have their own str converter, so fall back to repr instead,
which outputs '[', followed by the repr of each list item separated by
', ', followed by ']'.

> 2. Should the second print statement produce [ ║] or ["║"] ?

There's certainly no obvious reason why it *should*, and pretty decent
reasons why it shouldn't (it would be a hybrid mess of Python-syntax
repr output and raw string output).

> 3. Given that I want to print a list of Unicode strings so that their
> characters are displayed (instead of their Unicode codepoint definitions),
> is there a more Pythonic way of doing it than concatenating them into a
> single string and printing that?

print(' '.join(list_of_strings)) is probably most common. I suppose you
could do print(*list_of_strings) if you like, but I'm not sure I'd call
it "pythonic" as I've never seen anyone do that (that doesn't mean of
course that other people haven't seen it done!) Personally I only tend
to use print() for debugging output.

> 4. Does Python 3.x exhibit the same behaviour as Python 2.x in this respect?

Yes.

1
server_pubkey.txt

rocksolid light 0.9.7
clearnet tor