Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

But what can you do with it? -- ubiquitous cry from Linux-user partner


devel / comp.lang.python / RE: evaluation question

SubjectAuthor
* evaluation questionMuttley
+* Re: evaluation questionBen Bacarisse
|+- Re: evaluation questionMuttley
|`* Usenet vs. Mailing-list (was: evaluation question)Peter J. Holzer
| +* Re: Usenet vs. Mailing-list (was: evaluation question)Jon Ribbens
| |`* Re: Usenet vs. Mailing-listChris Green
| | +* Re: Usenet vs. Mailing-listChris Green
| | |`- Re: Usenet vs. Mailing-listChris Angelico
| | +* Re: Usenet vs. Mailing-listDennis Lee Bieber
| | |+- Re: Usenet vs. Mailing-listGrant Edwards
| | |+- Re: Usenet vs. Mailing-listAnssi Saari
| | |`- Re: Usenet vs. Mailing-listGrant Edwards
| | `- Re: Usenet vs. Mailing-listGrant Edwards
| +* Re: Usenet vs. Mailing-list (was: evaluation question)Dennis Lee Bieber
| |+- Re: Usenet vs. Mailing-list (was: evaluation question)Alan Gauld
| |`- Re: Usenet vs. Mailing-list (was: evaluation question)Grant Edwards
| `* Re: Usenet vs. Mailing-listBen Bacarisse
|  `* Re: Usenet vs. Mailing-listJon Ribbens
|   +* Re: Usenet vs. Mailing-listBen Bacarisse
|   |`* Re: Usenet vs. Mailing-listIgor Berger
|   | `- Re: Usenet vs. Mailing-listBen Bacarisse
|   `* Re: Usenet vs. Mailing-listPeter J. Holzer
|    `- Re: Usenet vs. Mailing-listJon Ribbens
+- Re: evaluation questionChris Angelico
+* Re: evaluation questiondn
|`* Re: evaluation questionMuttley
| `- Re: evaluation questionMark Bourne
`* Re: evaluation questionLouis Krupp
 `* Re: evaluation questionelvis-85792
  `* Re: evaluation questionThomas Passin
   `* Re: evaluation questionMuttley
    +- Re: evaluation questionRob Cliffe
    +* Re: evaluation questionGreg Ewing
    |+* Re: evaluation questionMuttley
    ||+* Re: evaluation questionThomas Passin
    |||`* Re: evaluation questionStefan Ram
    ||| +- Re: evaluation questionGreg Ewing
    ||| +- Re: evaluation questionChris Angelico
    ||| +* Re: evaluation questionThomas Passin
    ||| |`- Re: evaluation questionStefan Ram
    ||| `- Re: evaluation questionGrant Edwards
    ||+- RE: evaluation question<avi.e.gross
    ||+- Re: evaluation questionWeatherby,Gerard
    ||`* Re: evaluation questionGreg Ewing
    || +* Re: evaluation questiondn
    || |+- Re: evaluation questionGreg Ewing
    || |`* Re: evaluation questionMuttley
    || | +* Re: evaluation questionPeter J. Holzer
    || | |`* Re: evaluation questionMuttley
    || | | +* Re: evaluation questionrbowman
    || | | |`* Re: evaluation questionMuttley
    || | | | +- Re: evaluation questionGreg Ewing
    || | | | `- Re: evaluation questionrbowman
    || | | `- Re: evaluation questionMark Bourne
    || | +- Re: evaluation questionGrant Edwards
    || | +* Re: evaluation questionChris Angelico
    || | |`- Re: evaluation questionMuttley
    || | +* Re: evaluation questionChris Angelico
    || | |`- Re: evaluation questionMuttley
    || | `- Re: evaluation questionRob Cliffe
    || +* Re: evaluation questionMuttley
    || |+* Re: evaluation questionGrant Edwards
    || ||`- Re: evaluation questionMuttley
    || |+- Re: evaluation questionChris Angelico
    || |+- Re: evaluation questionRichard Damon
    || |`- Re: evaluation questionRichard Damon
    || +- Re: evaluation questionChris Angelico
    || `- Re: evaluation questionRob Cliffe
    |+* Re: evaluation questionMark Bourne
    ||`* Re: evaluation questionMuttley
    || `* Re: evaluation questionrbowman
    ||  `* Re: evaluation questionStefan Ram
    ||   `- Re: evaluation questionrbowman
    |`- RE: evaluation questionRobbie mezazem
    +- Re: evaluation questionPython
    +- Re: evaluation questionChris Angelico
    +- Re: evaluation questionPython
    +* Re: evaluation questionThomas Passin
    |`- Re: evaluation questionStefan Ram
    +- Re: evaluation questionChris Angelico
    +- RE: evaluation question<avi.e.gross
    +- Re: evaluation questionPython
    +- Re: evaluation questionWeatherby,Gerard
    `- RE: evaluation question<avi.e.gross

Pages:1234
Re: evaluation question

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ros...@gmail.com (Chris Angelico)
Newsgroups: comp.lang.python
Subject: Re: evaluation question
Date: Sat, 11 Feb 2023 08:30:22 +1100
Lines: 33
Message-ID: <mailman.1799.1676064637.20444.python-list@python.org>
References: <tr0uki$1p2c5$1@dont-email.me> <Ko8BL.57228$jiuc.57141@fx44.iad>
<slrnttdoeq.s20.elvis-85792@notatla.org.uk>
<bd4ffe68-8c09-b716-9f74-aa2d6abf1705@tompassin.net>
<mailman.1717.1675054683.20444.python-list@python.org>
<tr83bf$381e1$1@dont-email.me>
<20230210195907.GC4979@bladeshadow.org>
<CAPTjJmpBhNtpv5kBTu2wCJRV1HLx+ujsZz6QGsASmkW4XbW0yQ@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de KsNeMAY+gnTZCdslUecvJQCegpWk5TPkfZQm0oT1Lj7w==
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=OrhXqb28;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.004
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'this:': 0.03; '"python':
0.07; '2023': 0.07; 'e.g.': 0.07; 'string': 0.07; 'byte': 0.09;
'can,': 0.09; 'chrisa': 0.16; 'count.': 0.16; 'from:addr:rosuav':
0.16; 'from:name:chris angelico': 0.16; 'noting': 0.16; 'wrote:':
0.16; 'python': 0.16; 'subject:question': 0.17; 'feb': 0.17;
'instead': 0.17; 'figure': 0.19; 'to:addr:python-list': 0.20;
'sat,': 0.22; 'function': 0.27; 'output': 0.28; "doesn't": 0.32;
'message-id:@mail.gmail.com': 0.32; 'but': 0.32; 'able': 0.34;
'header:In-Reply-To:1': 0.34; 'received:google.com': 0.34;
'from:addr:gmail.com': 0.35; 'functions': 0.36; "it's": 0.37;
'received:209.85': 0.37; 'received:209': 0.39; 'quite': 0.39;
'received:209.85.208': 0.39; 'use': 0.39; 'something': 0.40;
'want': 0.40; 'tell': 0.60; 'job.': 0.62; 'simply': 0.63; 'skip:b
10': 0.63; 'username': 0.64; 'time,': 0.67; 'yourself': 0.75;
'of:': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=to:subject:message-id:date:from:in-reply-to:references:mime-version
:from:to:cc:subject:date:message-id:reply-to;
bh=Z/E3IUD7xRN73gl3Qq2eV1UQhk3h/vbodBUv8uiOhKw=;
b=OrhXqb289f3ZCcrRnzWTGFvnO1uXc62PuZZUn3LExT72CVOmOfVmvAup/ckcXCA9QY
G7O4yP1UL6yk3HhqZmRXvM7BEHALBPlUpNQzOtxpK7M+OJHEFo/lnQ+ecku2hms1uCu/
iigioYra4nJ9qQGH7rUNQk5BMTakXzMptKl18XkT0JLwU3Ko7zgTk8n6OI30wJv8MhoF
KnhDHCcUxNxmUAB0z0w4HrDrDDOiEyY/ypXxLcavn0C+hY7VQFzfL9lPnn9pJUc7vrfg
ttaf+RD9aV9wxtKVsj4fulz9c6KvPqckT8F+xb8wWVLvp0uxJhIUO3iZGQ9gDXHYlwkG
gsIw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=to:subject:message-id:date:from:in-reply-to:references:mime-version
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
bh=Z/E3IUD7xRN73gl3Qq2eV1UQhk3h/vbodBUv8uiOhKw=;
b=s3450a8zxRmlFRrpZgsDnL8DLyvvMk4G/dSrvKGxR1d2GqVRx45Sur/dIBSTSssRX9
/C6jOoYvOwI39cXT3Nez8AEOanGGpOfCQJNHUPF80lTNv0fPSsVKZDsh5gj7Y9La2gTL
guPtnl+JslNz6GNE6u3xWrNFW59/RxYtxvuhitIIF3vKIcGdCo6grOy6BFA1RCvb+voI
UvU6KpenD/hh8yaLrQWRgKE5sJORil1aLxOwMkgYXMtq8PLwHQUI5a5p/zOGQiFhxcwJ
a0IH4JuZXm9+u3zqFp9bla9V+qdMHkYrkk5WDT6Byz2IZEZ6yW2cuDsFqWqNo0gUEc4G
mKdQ==
X-Gm-Message-State: AO0yUKUIu7yM7OD27X1dSidk4eMU5ZXgDdXlSBdKBpacCS7MUWHEVtq8
JYUwYxUaL81lU7fk68zVDe3l9HhtJW4MigSg+sTeviHQ
X-Google-Smtp-Source: AK7set9rNu0Ab2XOo3EinZNfgyzcZbnE+K23PC7R2D4KvG+8MpdiU+gFDt1/53aMnsfj1k9gFvE1OCnrzmP49gIsGjg=
X-Received: by 2002:a50:9f65:0:b0:4ac:b38f:51a1 with SMTP id
b92-20020a509f65000000b004acb38f51a1mr419509edf.6.1676064634277; Fri, 10 Feb
2023 13:30:34 -0800 (PST)
In-Reply-To: <20230210195907.GC4979@bladeshadow.org>
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: <CAPTjJmpBhNtpv5kBTu2wCJRV1HLx+ujsZz6QGsASmkW4XbW0yQ@mail.gmail.com>
X-Mailman-Original-References: <tr0uki$1p2c5$1@dont-email.me>
<Ko8BL.57228$jiuc.57141@fx44.iad>
<slrnttdoeq.s20.elvis-85792@notatla.org.uk>
<bd4ffe68-8c09-b716-9f74-aa2d6abf1705@tompassin.net>
<mailman.1717.1675054683.20444.python-list@python.org>
<tr83bf$381e1$1@dont-email.me>
<20230210195907.GC4979@bladeshadow.org>
 by: Chris Angelico - Fri, 10 Feb 2023 21:30 UTC

On Sat, 11 Feb 2023 at 07:36, Python <python@bladeshadow.org> wrote:
> If it's the case that you simply want to know the length of the string
> that will be printed, you can, rather than expecting the I/O function
> to tell that to you, figure it out for yourself ahead of time, e.g.
> instead of:
>
> username = "John Smith"
> job = "Python programmer"
>
> # this doesn't work as desired
> len = print(f"{username} has occupation {job}.")
> print(len)
> ...
>
> You would do this instead:
>
> message = f"{username} has the occupation {job}."
> message_length = len(message)
> print(message)
> print(message_length)
> ...
>

It's worth noting WHY output functions often return a byte count. It's
primarily for use with nonblocking I/O, with something like this:

buffer = b".............."
buffer = buffer[os.write(fd, buffer):]

It's extremely important to be able to do this sort of thing, but not
with the print function, which has a quite different job.

ChrisA

Re: evaluation question

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: pyt...@bladeshadow.org (Python)
Newsgroups: comp.lang.python
Subject: Re: evaluation question
Date: Fri, 10 Feb 2023 15:55:37 -0600
Lines: 38
Message-ID: <mailman.1800.1676066204.20444.python-list@python.org>
References: <tr0uki$1p2c5$1@dont-email.me> <Ko8BL.57228$jiuc.57141@fx44.iad>
<slrnttdoeq.s20.elvis-85792@notatla.org.uk>
<bd4ffe68-8c09-b716-9f74-aa2d6abf1705@tompassin.net>
<mailman.1717.1675054683.20444.python-list@python.org>
<tr83bf$381e1$1@dont-email.me>
<20230210195907.GC4979@bladeshadow.org>
<CAPTjJmpBhNtpv5kBTu2wCJRV1HLx+ujsZz6QGsASmkW4XbW0yQ@mail.gmail.com>
<20230210215537.GD4979@bladeshadow.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
X-Trace: news.uni-berlin.de 4gfsFqdupv/9LLubifg2NAc+tyj691V44JMU5RTKkIEA==
Return-Path: <python@bladeshadow.org>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=none reason="no signature";
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.001
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'this:': 0.03; 'is.': 0.05;
"python's": 0.05; '2023': 0.07; 'string': 0.07; 'angelico': 0.09;
'blocking': 0.09; 'byte': 0.09; 'from:addr:python': 0.09;
'routine': 0.09; 'string,': 0.09; '+1100,': 0.16; 'applies': 0.16;
'call,': 0.16; 'count.': 0.16; 'from:name:python': 0.16; 'indeed':
0.16; 'noting': 0.16; 'wrapper': 0.16; 'wrote:': 0.16; 'python':
0.16; 'subject:question': 0.17; 'feb': 0.17; 'to:addr:python-
list': 0.20; 'returns': 0.22; 'sat,': 0.22; '11,': 0.26;
'function': 0.27; 'chris': 0.28; 'output': 0.28; 'asked': 0.29;
'header:User-Agent:1': 0.30; 'concerned': 0.32; 'context': 0.32;
'but': 0.32; 'able': 0.34; 'header:In-Reply-To:1': 0.34; 'trying':
0.35; 'particularly': 0.35; 'functions': 0.36; 'really': 0.37;
"it's": 0.37; 'though': 0.37; 'quite': 0.39; 'text': 0.39; 'use':
0.39; 'something': 0.40; 'format': 0.62; 'job.': 0.62; 'skip:b
10': 0.63; 'your': 0.64; 'small,': 0.69; "you'll": 0.73; 'mode,':
0.76; 'characters': 0.84; 'converted': 0.84; 'received:72': 0.84;
'say,': 0.84; 'transferred,': 0.84
Content-Disposition: inline
In-Reply-To: <CAPTjJmpBhNtpv5kBTu2wCJRV1HLx+ujsZz6QGsASmkW4XbW0yQ@mail.gmail.com>
User-Agent: Mutt/1.12.2 (2019-09-21)
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: <20230210215537.GD4979@bladeshadow.org>
X-Mailman-Original-References: <tr0uki$1p2c5$1@dont-email.me>
<Ko8BL.57228$jiuc.57141@fx44.iad>
<slrnttdoeq.s20.elvis-85792@notatla.org.uk>
<bd4ffe68-8c09-b716-9f74-aa2d6abf1705@tompassin.net>
<mailman.1717.1675054683.20444.python-list@python.org>
<tr83bf$381e1$1@dont-email.me>
<20230210195907.GC4979@bladeshadow.org>
<CAPTjJmpBhNtpv5kBTu2wCJRV1HLx+ujsZz6QGsASmkW4XbW0yQ@mail.gmail.com>
 by: Python - Fri, 10 Feb 2023 21:55 UTC

On Sat, Feb 11, 2023 at 08:30:22AM +1100, Chris Angelico wrote:
> On Sat, 11 Feb 2023 at 07:36, Python <python@bladeshadow.org> wrote:
> > You would do this instead:
> >
> > message = f"{username} has the occupation {job}."
> > message_length = len(message)
> > print(message)
> > print(message_length)
> > ...
> >
>
> It's worth noting WHY output functions often return a byte count. It's
> primarily for use with nonblocking I/O, with something like this:
>
> buffer = b".............."
> buffer = buffer[os.write(fd, buffer):]
>
> It's extremely important to be able to do this sort of thing, but not
> with the print function, which has a quite different job.

I would agree with this only partially. Your case applies to
os.write(), which is essentially just a wrapper around the write()
system call, which has that sort of property... though it applies also
to I/O in blocking mode, particularly on network sockets, where the
number of bytes you asked to write (or read) may not all have been
transferred, necessitating trying in a loop.

However, Python's print() function is more analogous to C's printf(),
which returns the number of characters converted for an entirely
different reason... It's precisely so that you'll know what the length
of the string that was converted is. This is most useful with the
*snprintf() variants where you're actually concerned about overrunning
the buffer you've provided for the output string, so you can realloc()
the buffer if it was indeed too small, but it is also useful in the
context of, say, a routine to format text according to the size of
your terminal. In that context it really has nothing to do with
blocking I/O or socket behavior.

Re: evaluation question

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.szaf.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: lis...@tompassin.net (Thomas Passin)
Newsgroups: comp.lang.python
Subject: Re: evaluation question
Date: Fri, 10 Feb 2023 17:48:53 -0500
Lines: 22
Message-ID: <mailman.1801.1676070394.20444.python-list@python.org>
References: <tr0uki$1p2c5$1@dont-email.me> <Ko8BL.57228$jiuc.57141@fx44.iad>
<slrnttdoeq.s20.elvis-85792@notatla.org.uk>
<bd4ffe68-8c09-b716-9f74-aa2d6abf1705@tompassin.net>
<mailman.1717.1675054683.20444.python-list@python.org>
<tr83bf$381e1$1@dont-email.me> <20230210195907.GC4979@bladeshadow.org>
<CAPTjJmpBhNtpv5kBTu2wCJRV1HLx+ujsZz6QGsASmkW4XbW0yQ@mail.gmail.com>
<20230210215537.GD4979@bladeshadow.org>
<b3d18627-a622-4279-118b-9cbfb8e9b2ab@tompassin.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de MO+DpE1bLUcZ/TsYB/NeQA3Cx7hn8B0zmT/0OJ0vEB+A==
Return-Path: <list1@tompassin.net>
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=tompassin.net header.i=@tompassin.net header.b=NY0g77hu;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.005
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'is.': 0.05; "python's":
0.05; 'string': 0.07; 'blocking': 0.09; 'routine': 0.09;
'string,': 0.09; 'terminal': 0.09; 'anything,': 0.16; 'applies':
0.16; 'buffer.': 0.16; 'displayed': 0.16; 'indeed': 0.16;
'received:10.0.0': 0.16; 'received:64.90': 0.16;
'received:64.90.62': 0.16; 'received:64.90.62.162': 0.16;
'received:dreamhost.com': 0.16; 'stdout.': 0.16; 'things,': 0.16;
'wrote:': 0.16; 'python': 0.16; 'subject:question': 0.17; 'pm,':
0.19; 'to:addr:python-list': 0.20; "i've": 0.22; 'returns': 0.22;
'actual': 0.25; 'function': 0.27; 'output': 0.28; 'printed': 0.28;
'header:User-Agent:1': 0.30; "doesn't": 0.32; 'concerned': 0.32;
'context': 0.32; 'received:10.0': 0.32;
'received:mailchannels.net': 0.32;
'received:relay.mailchannels.net': 0.32; 'but': 0.32; "i'm": 0.33;
'there': 0.33; 'header:In-Reply-To:1': 0.34; 'felt': 0.35; 'fine':
0.35; "we're": 0.35; 'display': 0.36; 'really': 0.37; "it's":
0.37; 'text': 0.39; 'something': 0.40; 'want': 0.40; 'physical':
0.60; 'format': 0.62; 'your': 0.64; 'header:Received:6': 0.67;
'received:64': 0.67; 'know.': 0.68; 'small,': 0.69; "you'll":
0.73; 'characters': 0.84; 'converted': 0.84; 'metrics': 0.84;
'say,': 0.84; 'graphic': 0.95
X-Sender-Id: dreamhost|x-authsender|tpassin@tompassin.net
ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1676069348; a=rsa-sha256;
cv=none;
b=hcLDdl4vg+CPn6XA/GrJ+nrIsDX+qPfe58dc/l40wILX57sb1P+saco4tuV55BYYibEQkI
BV/I9mdzicBvxO8G7Kzw7vOPQLYGCiwjf2MMHOdCvPIaXk3n1PVBfrQPOEp5DaFDMFV8Sr
MXqWsY03U+VtvRwWB3VjwK2zwU9guVGaoMy1ao5SLUhQ5FAsLJwqlB9s0rb6ZysHsVav67
stWG4ElFa5hxx2Sbge8miwkg2HXv9WeqxKNdJqxhQdsH4LlJcuuvdRPktHw3kCgRDsPkg/
x9Vj1UGY8leU+sa5CONBYa3nli1zftaIe6vj6MTov170dqxjrEIZ0IfuvTunGA==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed;
d=mailchannels.net; s=arc-2022; t=1676069348;
h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
to:to:cc:mime-version:mime-version:content-type:content-type:
content-transfer-encoding:content-transfer-encoding:
in-reply-to:in-reply-to:references:references:dkim-signature;
bh=krSewrzY9RDDN1nivjfVsjciZv0HASXysDvmobP8f0I=;
b=0TOu4TiMiNWupeZI4mD3h6vX2SDVZi5Z67yCt5uLWYCaWxFsvUCm9I8p23FSLDMsKlftMO
+LhFMyJ4e+viwrjIvzJmNxKcAaf6AUz2coK80n9UYLTS5Y4KqOstpcoMFBX+OEtRpaNgeH
b161AIbc2CBdH4/Xv455HtvujWSG2GqbWWXbIyEWVfy2PO6II9zWmzxtIfCmKEPBQwJifJ
YgkPwAWdU9x77B9m/qHjQ/aNbCe2CU8KmtTe+FDZJ9acO+caomQE21vCF7shyGP7oXUF7d
bTYOwrLKioIVD70Q1Z+FgjVyEdQEc3n5kqnKO4GxfVvUpMmdtoI0ThB9fni4Rw==
ARC-Authentication-Results: i=1; rspamd-759d9dd6cd-sv7xf;
auth=pass smtp.auth=dreamhost smtp.mailfrom=list1@tompassin.net
X-Sender-Id: dreamhost|x-authsender|tpassin@tompassin.net
X-MC-Relay: Neutral
X-MailChannels-SenderId: dreamhost|x-authsender|tpassin@tompassin.net
X-MailChannels-Auth-Id: dreamhost
X-White-Scare: 671450291bb3e160_1676069348754_1787252873
X-MC-Loop-Signature: 1676069348754:1740335343
X-MC-Ingress-Time: 1676069348754
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tompassin.net;
s=dreamhost; t=1676069348;
bh=krSewrzY9RDDN1nivjfVsjciZv0HASXysDvmobP8f0I=;
h=Date:Subject:To:From:Content-Type:Content-Transfer-Encoding;
b=NY0g77hujrKXTe0snl/yKVIbvDAJxrjnIsp0U5HQS/b2ewgjKdJwQG/MWA+vjYR64
BCFBQx5Q9YNE3gjIyyHfs1dHcieMaGkiVb/LGqoM4yYICmfWWugQorVoEdLBV6Ih0K
Fh5aAK15Uub6tlLCmH2ftipgFRV4cRmgbagP8vcD39skm1akac7ii0xvld/6L05WvE
/23N/HBzZjIs4p70ECQ4CUsEueJrj22tsPsVtL92Ylv3NsBvSNd+p+m77e6S/ELTBy
xz75wprerPjrhHjF5TKRrSaBtNJwmTEQTz23gGesF5e4n5XaB+T2ylsrVvvzfbdnDj
k8Bt+ckQmSj9Q==
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.7.2
Content-Language: en-US
In-Reply-To: <20230210215537.GD4979@bladeshadow.org>
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: <b3d18627-a622-4279-118b-9cbfb8e9b2ab@tompassin.net>
X-Mailman-Original-References: <tr0uki$1p2c5$1@dont-email.me>
<Ko8BL.57228$jiuc.57141@fx44.iad>
<slrnttdoeq.s20.elvis-85792@notatla.org.uk>
<bd4ffe68-8c09-b716-9f74-aa2d6abf1705@tompassin.net>
<mailman.1717.1675054683.20444.python-list@python.org>
<tr83bf$381e1$1@dont-email.me> <20230210195907.GC4979@bladeshadow.org>
<CAPTjJmpBhNtpv5kBTu2wCJRV1HLx+ujsZz6QGsASmkW4XbW0yQ@mail.gmail.com>
<20230210215537.GD4979@bladeshadow.org>
 by: Thomas Passin - Fri, 10 Feb 2023 22:48 UTC

On 2/10/2023 4:55 PM, Python wrote:
> However, Python's print() function is more analogous to C's printf(),
> which returns the number of characters converted for an entirely
> different reason... It's precisely so that you'll know what the length
> of the string that was converted is. This is most useful with the
> *snprintf() variants where you're actually concerned about overrunning
> the buffer you've provided for the output string, so you can realloc()
> the buffer if it was indeed too small, but it is also useful in the
> context of, say, a routine to format text according to the size of
> your terminal. In that context it really has nothing to do with
> blocking I/O or socket behavior.

But none of that applies to the Python print() function. There are no
buffers to overrun, no reason to know the length of the printed string,
no re-allocating of a buffer. It's certainly possible that one might
want to know the actual physical length of a displayed string - perhaps
to display it on a graphic - but now we're getting into font metrics and
such things, and we'll be doing something more active than displaying on
a terminal via stdout.

I don't know why the print() function doesn't return anything, but I'm
fine with it. I've never felt that I needed to know.

Re: evaluation question

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.szaf.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: ros...@gmail.com (Chris Angelico)
Newsgroups: comp.lang.python
Subject: Re: evaluation question
Date: Sat, 11 Feb 2023 10:10:33 +1100
Lines: 27
Message-ID: <mailman.1802.1676070647.20444.python-list@python.org>
References: <tr0uki$1p2c5$1@dont-email.me> <Ko8BL.57228$jiuc.57141@fx44.iad>
<slrnttdoeq.s20.elvis-85792@notatla.org.uk>
<bd4ffe68-8c09-b716-9f74-aa2d6abf1705@tompassin.net>
<mailman.1717.1675054683.20444.python-list@python.org>
<tr83bf$381e1$1@dont-email.me>
<20230210195907.GC4979@bladeshadow.org>
<CAPTjJmpBhNtpv5kBTu2wCJRV1HLx+ujsZz6QGsASmkW4XbW0yQ@mail.gmail.com>
<20230210215537.GD4979@bladeshadow.org>
<b3d18627-a622-4279-118b-9cbfb8e9b2ab@tompassin.net>
<CAPTjJmq_=cqUZz8fzxyhDTJfwNyUUttU1q2erXLy9QwLo7PEDw@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de pPRJLvPDJqrioPGumD1AJAjZmilyM+ZgDLTg7tLdsm7w==
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=CyHDCr3r;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.003
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'is.': 0.05; "python's":
0.05; '2023': 0.07; 'string': 0.07; 'blocking': 0.09; 'routine':
0.09; 'string,': 0.09; 'terminal': 0.09; 'applies': 0.16;
'buffer.': 0.16; 'chrisa': 0.16; 'displayed': 0.16; 'displaying.':
0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16;
'indeed': 0.16; 'stdout': 0.16; 'stdout.': 0.16; 'things,': 0.16;
'wrote:': 0.16; 'python': 0.16; 'subject:question': 0.17; 'feb':
0.17; 'pm,': 0.19; 'to:addr:python-list': 0.20; 'first,': 0.22;
'returns': 0.22; 'sat,': 0.22; 'actual': 0.25; 'function': 0.27;
'output': 0.28; 'printed': 0.28; 'concerned': 0.32; 'context':
0.32; 'message-id:@mail.gmail.com': 0.32; 'but': 0.32; 'there':
0.33; 'header:In-Reply-To:1': 0.34; 'received:google.com': 0.34;
'from:addr:gmail.com': 0.35; "we're": 0.35; 'display': 0.36;
'really': 0.37; "it's": 0.37; 'received:209.85': 0.37;
'received:209': 0.39; 'text': 0.39; 'received:209.85.208': 0.39;
'something': 0.40; 'want': 0.40; 'physical': 0.60; 'format': 0.62;
'your': 0.64; 'generally': 0.67; 'small,': 0.69; "you'll": 0.73;
'formatting': 0.76; 'characters': 0.84; 'converted': 0.84;
'metrics': 0.84; 'say,': 0.84; 'graphic': 0.95
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=to:subject:message-id:date:from:in-reply-to:references:mime-version
:from:to:cc:subject:date:message-id:reply-to;
bh=xFZeHQPukfUHUwgeQfgHv8RjRAE9vpX5h3y6a/i6Vjk=;
b=CyHDCr3rhDLRUa3ZVqN01ufMVXoxVfwIvgUowixA0C7KU6dpukAdMjh9UlkoTrroMX
AqBR/QCE6cNhKQoausiqnjrVi1MbX+xCIXEjUcLGFJcB25/UR1g3kVUizXFY3qo0PZ+R
Ztf0xHBYkmvPHcjwODQ049lpWxe+nS+LrduASkhZlged+MZcCjDs1Y9fyk5WzlplVBIA
CzI97QDlWXA84cQxiyUzL5EwOzbEkduDz/SAfiv+iEb+durwllWRxyLeXaztyT4QWsvr
FSxIaqkHewy/iV1JYei/zzwI8vOQEckbccrImJi/juzHoEwQqNLIXexdqT0vg4cMhwtk
ICQg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=to:subject:message-id:date:from:in-reply-to:references:mime-version
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
bh=xFZeHQPukfUHUwgeQfgHv8RjRAE9vpX5h3y6a/i6Vjk=;
b=XR2LiGXXQkNU68EQ+Fevx5AiXxBD5GGKUF6KbBJxvVvBvQErMe/trD2AW1bhmHWEY8
C/PO/lMIrgStEDnLAToo/C6Jx8gX+06uWWA3gMZP3H7sAJXTTRYQobzVcEMYuz7Mir96
qrCXbJ+wgSTb8hQX5GgIQ+UBoz0ptA4wSlwsL/5Qj+gkNXuoGiaV5wTw8AG2G8n191ZL
I30DcC3hcBxwQzi8NaLFEJ4KXi7rRxLhEt/cN6UTusqHWt5en/TwpuVZc5ddAalp3g4t
38STQsUgCgbeZgScuc8ZvnROkv5/ZriaGXG6C3KSGO2VGHNZCDq6n7DXod9ECCjzyuIq
PXUw==
X-Gm-Message-State: AO0yUKUCDPQNv8S8Krj6xgelYEQAcxFgvBIAZS7ieDeDCCCmQ2fwjzLn
+EXUKB1QHq+8XFh8rbdeIsG9Ea12PJXJLKp/OV98AY/t
X-Google-Smtp-Source: AK7set+qH/1YfsfyD1iuLPFGLB43GM1XngFPKvmsQCl5N8t8AMrLfCnVR9fGV5sP7jMsz9Vzemz3gyHvq8WKNGibyRM=
X-Received: by 2002:a50:f68d:0:b0:4ac:b618:7fb1 with SMTP id
d13-20020a50f68d000000b004acb6187fb1mr221536edn.6.1676070645216; Fri, 10 Feb
2023 15:10:45 -0800 (PST)
In-Reply-To: <b3d18627-a622-4279-118b-9cbfb8e9b2ab@tompassin.net>
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: <CAPTjJmq_=cqUZz8fzxyhDTJfwNyUUttU1q2erXLy9QwLo7PEDw@mail.gmail.com>
X-Mailman-Original-References: <tr0uki$1p2c5$1@dont-email.me>
<Ko8BL.57228$jiuc.57141@fx44.iad>
<slrnttdoeq.s20.elvis-85792@notatla.org.uk>
<bd4ffe68-8c09-b716-9f74-aa2d6abf1705@tompassin.net>
<mailman.1717.1675054683.20444.python-list@python.org>
<tr83bf$381e1$1@dont-email.me>
<20230210195907.GC4979@bladeshadow.org>
<CAPTjJmpBhNtpv5kBTu2wCJRV1HLx+ujsZz6QGsASmkW4XbW0yQ@mail.gmail.com>
<20230210215537.GD4979@bladeshadow.org>
<b3d18627-a622-4279-118b-9cbfb8e9b2ab@tompassin.net>
 by: Chris Angelico - Fri, 10 Feb 2023 23:10 UTC

On Sat, 11 Feb 2023 at 10:07, Thomas Passin <list1@tompassin.net> wrote:
>
> On 2/10/2023 4:55 PM, Python wrote:
> > However, Python's print() function is more analogous to C's printf(),
> > which returns the number of characters converted for an entirely
> > different reason... It's precisely so that you'll know what the length
> > of the string that was converted is. This is most useful with the
> > *snprintf() variants where you're actually concerned about overrunning
> > the buffer you've provided for the output string, so you can realloc()
> > the buffer if it was indeed too small, but it is also useful in the
> > context of, say, a routine to format text according to the size of
> > your terminal. In that context it really has nothing to do with
> > blocking I/O or socket behavior.
>
> But none of that applies to the Python print() function. There are no
> buffers to overrun, no reason to know the length of the printed string,
> no re-allocating of a buffer. It's certainly possible that one might
> want to know the actual physical length of a displayed string - perhaps
> to display it on a graphic - but now we're getting into font metrics and
> such things, and we'll be doing something more active than displaying on
> a terminal via stdout.

It's sometimes possible to have that go to stdout (maybe you want to
do columnar text or something), but yeah, you'll generally do that by
formatting first, then doing the measurement, then displaying.

ChrisA

Re: evaluation question

<return-20230211001633@ram.dialup.fu-berlin.de>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram...@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Re: evaluation question
Date: 10 Feb 2023 23:17:05 GMT
Organization: Stefan Ram
Lines: 14
Expires: 1 Jan 2024 11:59:58 GMT
Message-ID: <return-20230211001633@ram.dialup.fu-berlin.de>
References: <tr0uki$1p2c5$1@dont-email.me> <Ko8BL.57228$jiuc.57141@fx44.iad> <slrnttdoeq.s20.elvis-85792@notatla.org.uk> <bd4ffe68-8c09-b716-9f74-aa2d6abf1705@tompassin.net> <mailman.1717.1675054683.20444.python-list@python.org> <tr83bf$381e1$1@dont-email.me> <20230210195907.GC4979@bladeshadow.org> <CAPTjJmpBhNtpv5kBTu2wCJRV1HLx+ujsZz6QGsASmkW4XbW0yQ@mail.gmail.com> <20230210215537.GD4979@bladeshadow.org> <b3d18627-a622-4279-118b-9cbfb8e9b2ab@tompassin.net> <mailman.1801.1676070394.20444.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de SuZPtJFHrTM5Mg9efIreugndw5ZoBQVC7QLhnPGOsscUrZ
X-Copyright: (C) Copyright 2023 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Accept-Language: de-DE, en-US, it, fr-FR
 by: Stefan Ram - Fri, 10 Feb 2023 23:17 UTC

Thomas Passin <list1@tompassin.net> writes:
>I don't know why the print() function doesn't return anything, but I'm
>fine with it. I've never felt that I needed to know.

There is one important reason for procedures to return something:
Many procedures can fail under certain circumstances.
The caller often needs a report about whether the procedure failed.
This is the return value.

When a programming language has exceptions, then these are
often used to return error reports. This often eliminates
the need for further reports.

RE: evaluation question

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From:
Newsgroups: comp.lang.python
Subject: RE: evaluation question
Date: Fri, 10 Feb 2023 18:17:42 -0500
Lines: 91
Message-ID: <mailman.1803.1676071067.20444.python-list@python.org>
References: <tr0uki$1p2c5$1@dont-email.me> <Ko8BL.57228$jiuc.57141@fx44.iad>
<slrnttdoeq.s20.elvis-85792@notatla.org.uk>
<bd4ffe68-8c09-b716-9f74-aa2d6abf1705@tompassin.net>
<mailman.1717.1675054683.20444.python-list@python.org>
<tr83bf$381e1$1@dont-email.me> <20230210195907.GC4979@bladeshadow.org>
<CAPTjJmpBhNtpv5kBTu2wCJRV1HLx+ujsZz6QGsASmkW4XbW0yQ@mail.gmail.com>
<20230210215537.GD4979@bladeshadow.org>
<003501d93da5$e0b00330$a2100990$@gmail.com>
Mime-Version: 1.0
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de XhYskgldxjpFKjFzWggppQtKMw6ef0erv/7E3q7Qf7Tw==
Return-Path: <avi.e.gross@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=BoTLcQmi;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.001
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'this:': 0.03; 'knows':
0.04; 'is.': 0.05; "python's": 0.05; '2023': 0.07; 'spaces': 0.07;
'string': 0.07; 'angelico': 0.09; 'blocking': 0.09; 'byte': 0.09;
'characters,': 0.09; 'deeper': 0.09; 'floating': 0.09;
'received:108': 0.09; 'routine': 0.09; 'situations': 0.09;
'string,': 0.09; 'url:mailman': 0.15; '+1100,': 0.16; 'anything,':
0.16; 'apl': 0.16; 'applies': 0.16; 'call,': 0.16; 'characters.':
0.16; 'count.': 0.16; 'decimal': 0.16; 'efficiently': 0.16;
'fonts,': 0.16; 'indeed': 0.16; 'noting': 0.16; 'specify': 0.16;
'ways.': 0.16; 'wrapper': 0.16; 'wrote:': 0.16; 'python': 0.16;
'subject:question': 0.17; 'feb': 0.17; 'message-id:@gmail.com':
0.18; 'calls': 0.19; 'to:addr:python-list': 0.20; 'doubt': 0.22;
'returns': 0.22; 'sat,': 0.22; 'lines': 0.23; 'anything': 0.25;
'skip:- 10': 0.25; 'url-ip:188.166.95.178/32': 0.25; 'url-
ip:188.166.95/24': 0.25; 'url:listinfo': 0.25; 'url-
ip:188.166/16': 0.25; 'space': 0.26; '11,': 0.26; 'again,': 0.26;
'friday,': 0.26; 'else': 0.27; 'function': 0.27; 'done': 0.28;
'chris': 0.28; 'mostly': 0.28; 'output': 0.28; 'settings': 0.28;
'example,': 0.28; 'printed': 0.28; 'this?': 0.29; 'asked': 0.29;
'takes': 0.31; 'putting': 0.31; 'received:209.85.160': 0.31; 'url-
ip:188/8': 0.31; 'program': 0.31; 'question': 0.32; 'assume':
0.32; 'concerned': 0.32; 'context': 0.32; 'objects': 0.32;
'python-list': 0.32; 'zero': 0.32; 'but': 0.32; 'there': 0.33;
'someone': 0.34; 'able': 0.34; 'package': 0.34; 'printing': 0.34;
'header:In-Reply-To:1': 0.34; 'received:google.com': 0.34;
'trying': 0.35; 'particularly': 0.35; 'from:addr:gmail.com': 0.35;
'request': 0.35; 'cases': 0.36; 'display': 0.36; 'functions':
0.36; 'people': 0.36; 'really': 0.37; "it's": 0.37;
'received:209.85': 0.37; 'others': 0.37; 'though': 0.37; 'way':
0.38; 'received:209': 0.39; 'quite': 0.39; 'text': 0.39; 'use':
0.39; 'decide': 0.39; 'evaluation': 0.39; 'methods': 0.39; 'on.':
0.39; 'still': 0.40; 'wants': 0.40; 'something': 0.40; 'want':
0.40; '10,': 0.61; 'here.': 0.61; 'from:': 0.62; 'to:': 0.62;
'format': 0.62; 'job.': 0.62; 'lower': 0.62; 'skip:b 10': 0.63;
'imagine': 0.64; 're:': 0.64; 'your': 0.64; 'parts': 0.65; 'let':
0.66; 'accept': 0.67; 'away': 0.67; 'and,': 0.69; 'small,': 0.69;
'track,': 0.69; 'varying': 0.69; 'longer': 0.71; "you'll": 0.73;
'formatting': 0.76; 'mode,': 0.76; 'sent:': 0.78; 'field': 0.78;
'besides,': 0.84; 'characters': 0.84; 'converted': 0.84;
'levels.': 0.84; 'say,': 0.84; 'transferred,': 0.84; 'width': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=content-language:thread-index:content-transfer-encoding
:mime-version:message-id:date:subject:in-reply-to:references:to:from
:from:to:cc:subject:date:message-id:reply-to;
bh=8znYGhGDzVu0oHNn5t1rN9wopNQ64pwUiWTrZJF24kY=;
b=BoTLcQmik1UcvaxxxPqk7gcjXXX0hkZyk4KXq23dnT2QXZ9itcUMAvQHsDNGFNvZEX
KFKuw0JxqCjDmfJLJvKoPHLW8vBEs48KYOm21B1AJv3OChp9wKX76IKtPgoc5my/ilmz
2dTbkk5KC58v1Dd/A7dv+O3vqMOktMPMokq/MHUOuQwrShhWNKr2PdYQ6Yy+9TMKdZNE
OxXWTcgmDyiMPoDPHd7SdBZUtzhLup5F4vAwonGC2Yf9RqXE6haE9KcrobKNoka7uWix
D8ENEtXWp9YL5ur+LRSI7xLWAVRfo3Q6DDF87SaeanY80TQi7zOovcz4YCF+/BxnY+lz
VHTw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=content-language:thread-index:content-transfer-encoding
:mime-version:message-id:date:subject:in-reply-to:references:to:from
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
bh=8znYGhGDzVu0oHNn5t1rN9wopNQ64pwUiWTrZJF24kY=;
b=dkobm7XOXcFRumRjOGxJelpDxa3WU4hWclPpL9+V3yFombaSo9xD74OibamVsdMZl2
HMbsBSA/ybedZIm3TrMiZ6jrdOMYFACE3EyEiByf5ZKtG87a3kYkgtnJwoFMmnGKvAZ6
0YjKA3OXAQrle8oURpj5E70uu1vzvk0/yNZ3hgOjIb/7ciEneryY1G0MR//gCLWcObiM
zkL+p5TWe60QmktND5kne9JG9dww4yPkdQBMeW6D0rxx7o/RDxQM1Fh6+bqxnNH29fjX
QuFP0tJTP5tyco2p4ntzEOd5Kjh9RAlSPCfu9hQb1Iwk3yf1wAvNUkDnqTnbFfmsP6Tz
DKBA==
X-Gm-Message-State: AO0yUKU2pmvMJ3EZvXIEzQqkOAQUN6FB3FMn526l6E0woleUmXW+y0Di
zQtT1yIM3hCpYfRLfukgGxadpOOLEXg=
X-Google-Smtp-Source: AK7set+f8aWf4kr49jcvRORuhEd6RfFseVGDe5n0O3SoXOPToRp2RRjDDSgAzRgQX5kzpwO0BbAKvA==
X-Received: by 2002:a05:622a:1ba2:b0:3b9:e0b2:9a49 with SMTP id
bp34-20020a05622a1ba200b003b9e0b29a49mr23920939qtb.60.1676071064114;
Fri, 10 Feb 2023 15:17:44 -0800 (PST)
In-Reply-To: <20230210215537.GD4979@bladeshadow.org>
X-Mailer: Microsoft Outlook 16.0
Thread-Index: AQJBjeeZndWAK5y41s73pA9LvyXagQEV1S1DAqSKeDACXv8iAAJcdE9hAqvJZV8B1urwdQHo9Q2cAtyyCAutajpe4A==
Content-Language: en-us
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: <003501d93da5$e0b00330$a2100990$@gmail.com>
X-Mailman-Original-References: <tr0uki$1p2c5$1@dont-email.me>
<Ko8BL.57228$jiuc.57141@fx44.iad> <slrnttdoeq.s20.elvis-85792@notatla.org.uk>
<bd4ffe68-8c09-b716-9f74-aa2d6abf1705@tompassin.net>
<mailman.1717.1675054683.20444.python-list@python.org>
<tr83bf$381e1$1@dont-email.me> <20230210195907.GC4979@bladeshadow.org>
<CAPTjJmpBhNtpv5kBTu2wCJRV1HLx+ujsZz6QGsASmkW4XbW0yQ@mail.gmail.com>
<20230210215537.GD4979@bladeshadow.org>
 by: - Fri, 10 Feb 2023 23:17 UTC

There are no doubt many situations someone wants to know how long something
will be when printed but often at lower levels.

In variable-width fonts, for example, the number of characters does not
really line up precisely with how many characters. Some encodings use a
varying number of bytes and, again, the width of the output varies.

So for people who want to make 2-D formatted output like tables, or who want
to wrap lines longer than N characters, you more often let some deeper
software accept your data and decide on formatting it internally and either
print it at once, when done calculating, or in the case of some old-style
terminals, use something like the curses package that may use escape
sequences to update the screen more efficiently in various ways.

If someone wants more control over what they print, rather than asking the
print() function to return something that is mostly going to be ignored,
they can do the things others have already suggested here. You can make your
message parts in advance and measure their length or anything else before
you print. Or make a wrapper that does something for you before calling
print, perhaps only for common cases and then returns the length to you
after printing.

I wonder if the next request will be for print() to know what your output
device is and other current settings so it return the width your text takes
up in pixels in the current font/size ...

I add a tidbit that many ways of printing allow you to specify the width you
want something printed in such as you want a floating point value with so
many digits after the decimal point in a zero or space padded field on the
left. So there are ways to calculate in advance for many common cases as to
how long each part will be if you specify it. Besides, I am not really sure
if "print" even knows easily how many characters it is putting out as it
chews away on the many things in your request and calls dunder methods in
objects so they display themselves and so on. I assume it can be made to
keep track, albeit I can imagine printing out an APL program with lots of
overwritten characters where the number of bytes sent is way more than the
number of spaces in the output.

Why are we even still talking about this? The answer to the question of why
print() does not return anything, let alone the number of characters
printed, is BECAUSE.

-----Original Message-----
From: Python-list <python-list-bounces+avi.e.gross=gmail.com@python.org> On
Behalf Of Python
Sent: Friday, February 10, 2023 4:56 PM
To: python-list@python.org
Subject: Re: evaluation question

On Sat, Feb 11, 2023 at 08:30:22AM +1100, Chris Angelico wrote:
> On Sat, 11 Feb 2023 at 07:36, Python <python@bladeshadow.org> wrote:
> > You would do this instead:
> >
> > message = f"{username} has the occupation {job}."
> > message_length = len(message)
> > print(message)
> > print(message_length)
> > ...
> >
>
> It's worth noting WHY output functions often return a byte count. It's
> primarily for use with nonblocking I/O, with something like this:
>
> buffer = b".............."
> buffer = buffer[os.write(fd, buffer):]
>
> It's extremely important to be able to do this sort of thing, but not
> with the print function, which has a quite different job.

I would agree with this only partially. Your case applies to os.write(),
which is essentially just a wrapper around the write() system call, which
has that sort of property... though it applies also to I/O in blocking mode,
particularly on network sockets, where the number of bytes you asked to
write (or read) may not all have been transferred, necessitating trying in a
loop.

However, Python's print() function is more analogous to C's printf(), which
returns the number of characters converted for an entirely different
reason... It's precisely so that you'll know what the length of the string
that was converted is. This is most useful with the
*snprintf() variants where you're actually concerned about overrunning the
buffer you've provided for the output string, so you can realloc() the
buffer if it was indeed too small, but it is also useful in the context of,
say, a routine to format text according to the size of your terminal. In
that context it really has nothing to do with blocking I/O or socket
behavior.

--
https://mail.python.org/mailman/listinfo/python-list

Re: evaluation question

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: pyt...@bladeshadow.org (Python)
Newsgroups: comp.lang.python
Subject: Re: evaluation question
Date: Fri, 10 Feb 2023 20:10:43 -0600
Lines: 63
Message-ID: <mailman.1804.1676081509.20444.python-list@python.org>
References: <tr0uki$1p2c5$1@dont-email.me> <Ko8BL.57228$jiuc.57141@fx44.iad>
<slrnttdoeq.s20.elvis-85792@notatla.org.uk>
<bd4ffe68-8c09-b716-9f74-aa2d6abf1705@tompassin.net>
<mailman.1717.1675054683.20444.python-list@python.org>
<tr83bf$381e1$1@dont-email.me>
<20230210195907.GC4979@bladeshadow.org>
<CAPTjJmpBhNtpv5kBTu2wCJRV1HLx+ujsZz6QGsASmkW4XbW0yQ@mail.gmail.com>
<20230210215537.GD4979@bladeshadow.org>
<b3d18627-a622-4279-118b-9cbfb8e9b2ab@tompassin.net>
<20230211021043.GE4979@bladeshadow.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
X-Trace: news.uni-berlin.de MIA5VLdkV1L7JQtagP8InQcab2HZB/Cwsa8VR7V8pdRg==
Return-Path: <python@bladeshadow.org>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=none reason="no signature";
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.002
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'is.': 0.05; "python's":
0.05; '2023': 0.07; 'e.g.': 0.07; 'string': 0.07; 'underlying':
0.07; 'blocking': 0.09; 'breaks': 0.09; 'from:addr:python': 0.09;
'indeed.': 0.09; 'originally': 0.09; 'post.': 0.09; 'routine':
0.09; 'string,': 0.09; 'unlike': 0.09; 'adequately': 0.16;
'applies': 0.16; 'buffer.': 0.16; 'calculation': 0.16;
'demonstrated': 0.16; 'from:name:python': 0.16; 'indeed': 0.16;
'length.': 0.16; 'outputting': 0.16; 'something.': 0.16; 'stdout':
0.16; 'though!': 0.16; 'thread.': 0.16; 'wrote:': 0.16; 'python':
0.16; 'subject:question': 0.17; 'feb': 0.17; 'probably': 0.17;
"can't": 0.17; 'calls': 0.19; 'pm,': 0.19; 'to:addr:python-list':
0.20; 'languages': 0.22; 'basically': 0.22; 'fri,': 0.22; 'maybe':
0.22; 'returns': 0.22; 'anything': 0.25; 'register': 0.25;
"wasn't": 0.26; 'else': 0.27; 'bit': 0.27; 'function': 0.27;
'output': 0.28; 'sense': 0.28; 'printed': 0.28; 'error': 0.29;
'header:User-Agent:1': 0.30; 'raise': 0.31; "doesn't": 0.32;
'aims': 0.32; 'concerned': 0.32; 'context': 0.32; 'point,': 0.32;
'unless': 0.32; 'but': 0.32; 'there': 0.33; 'header:In-Reply-
To:1': 0.34; 'functions': 0.36; 'really': 0.37; 'using': 0.37;
"it's": 0.37; 'could': 0.38; 'means': 0.38; 'put': 0.38; 'adding':
0.39; 'text': 0.39; 'sending': 0.39; 'mentioned': 0.39; 'to.':
0.39; 'wants': 0.40; 'want': 0.40; 'tell': 0.60; '10,': 0.61;
"there's": 0.61; 'format': 0.62; 'explained': 0.64; 'your': 0.64;
'less': 0.65; 'earlier': 0.67; 'small,': 0.69; 'strategy.': 0.69;
'depending': 0.70; 'compared': 0.71; 'ignore': 0.71; 'free': 0.72;
'relevant': 0.73; "you'll": 0.73; 'covered': 0.75; 'formatting':
0.76; 'returned': 0.81; 'characters': 0.84; 'converted': 0.84;
'efficiency.': 0.84; 'received:72': 0.84; 'return?': 0.84; 'say,':
0.84; 'written,': 0.84; '"do': 0.91; 'of:': 0.91
Content-Disposition: inline
In-Reply-To: <b3d18627-a622-4279-118b-9cbfb8e9b2ab@tompassin.net>
User-Agent: Mutt/1.12.2 (2019-09-21)
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: <20230211021043.GE4979@bladeshadow.org>
X-Mailman-Original-References: <tr0uki$1p2c5$1@dont-email.me>
<Ko8BL.57228$jiuc.57141@fx44.iad>
<slrnttdoeq.s20.elvis-85792@notatla.org.uk>
<bd4ffe68-8c09-b716-9f74-aa2d6abf1705@tompassin.net>
<mailman.1717.1675054683.20444.python-list@python.org>
<tr83bf$381e1$1@dont-email.me>
<20230210195907.GC4979@bladeshadow.org>
<CAPTjJmpBhNtpv5kBTu2wCJRV1HLx+ujsZz6QGsASmkW4XbW0yQ@mail.gmail.com>
<20230210215537.GD4979@bladeshadow.org>
<b3d18627-a622-4279-118b-9cbfb8e9b2ab@tompassin.net>
 by: Python - Sat, 11 Feb 2023 02:10 UTC

On Fri, Feb 10, 2023 at 05:48:53PM -0500, Thomas Passin wrote:
> On 2/10/2023 4:55 PM, Python wrote:
> > However, Python's print() function is more analogous to C's printf(),
> > which returns the number of characters converted for an entirely
> > different reason... It's precisely so that you'll know what the length
> > of the string that was converted is. This is most useful with the
> > *snprintf() variants where you're actually concerned about overrunning
> > the buffer you've provided for the output string, so you can realloc()
> > the buffer if it was indeed too small, but it is also useful in the
> > context of, say, a routine to format text according to the size of
> > your terminal. In that context it really has nothing to do with
> > blocking I/O or socket behavior.
>
> But none of that applies to the Python print() function. There are no
> buffers to overrun, no reason to know the length of the printed string, no
> re-allocating of a buffer.

Indeed. But the OP originally compared print to printf, and I was
specifically addressing Chris' point about why I/O functions return
the number of bytes written, which was relevant to, but maybe a bit of
tangent to the original post.
> I don't know why the print() function doesn't return anything

You do though! :) You actually just explained why yourself... it's
because it just doesn't need to. But FWIW, I wasn't addressing this
point, because it had already been adequately covered in the thread.

There's good reason why Python's print and C's printf work
differently. In languages like C it makes sense that printf returns
the length of the string. printf is the means of all three of:

- formatting the string
- counting its length
- actually outputting the string to stdout (albeit indirectly).

This sort of breaks the rule of, "do one thing, and do it well," but
it does so in the name of efficiency. You might or might not want to
actually know the length of the formatted string, depending on what
you're doing with it. But the printf function basically needs to
calculate it anyway so that it can tell the underlying system calls
how many bytes to write (or tell stdio how many bytes it is adding to
its buffers, or whatever), and then stuffing that length in a register
to be returned to the caller is roughly free (it's probably using the
register that it's going to return already to do the counting), and
the caller can ignore it if it wants to. C aims to be as efficient as
possible so this is a good strategy.

Unlike C[*], since Python can already separate the formatting and
length calculation from sending the data to stdout (I demonstrated how
in my first post in the thread), it has no need for print to return
the length. As I mentioned in my earlier post, if Python encounters
an error condition it will raise an exception--which C can't do--so
there's no reason to return a status either. What else would it
return? Nothing else would really make sense.

-=-=-=-
* In C you could sprintf the string into a buffer, which would return
its length, and then call printf on the buffer, but that would be much
less efficient and a bit silly... UNLESS you actually needed to know
the length of the string beforehand, e.g. to calculate where to put
line breaks in a text justification routine, or something.

Re: evaluation question

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: gweathe...@uchc.edu (Weatherby,Gerard)
Newsgroups: comp.lang.python
Subject: Re: evaluation question
Date: Mon, 13 Feb 2023 15:15:43 +0000
Lines: 121
Message-ID: <mailman.1813.1676301977.20444.python-list@python.org>
References: <tr0uki$1p2c5$1@dont-email.me> <Ko8BL.57228$jiuc.57141@fx44.iad>
<slrnttdoeq.s20.elvis-85792@notatla.org.uk>
<bd4ffe68-8c09-b716-9f74-aa2d6abf1705@tompassin.net>
<mailman.1717.1675054683.20444.python-list@python.org>
<tr83bf$381e1$1@dont-email.me> <20230210195907.GC4979@bladeshadow.org>
<CAPTjJmpBhNtpv5kBTu2wCJRV1HLx+ujsZz6QGsASmkW4XbW0yQ@mail.gmail.com>
<20230210215537.GD4979@bladeshadow.org>
<003501d93da5$e0b00330$a2100990$@gmail.com>
<SJ0PR14MB5864008AC2BC8C0CF96BDC4CB9DD9@SJ0PR14MB5864.namprd14.prod.outlook.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de nBezd536W+u7+C09cHVRqgkVdw20lPRoVgTluDFDgVFA==
Return-Path: <prvs=0408baf6ea=gweatherby@uchc.edu>
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=uchc.edu header.i=@uchc.edu header.b=JP05YK4z;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.003
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'this:': 0.03; 'knows':
0.04; 'is.': 0.05; "python's": 0.05; '2023': 0.07; 'spaces': 0.07;
'string': 0.07; 'angelico': 0.09; 'blocking': 0.09; 'byte': 0.09;
'characters,': 0.09; 'deeper': 0.09; 'floating': 0.09;
'received:namprd14.prod.outlook.com': 0.09; 'routine': 0.09;
'situations': 0.09; 'string,': 0.09; '&gt;': 0.14; 'url:mailman':
0.15; '***': 0.16; '+1100,': 0.16; 'anything,': 0.16; 'apl': 0.16;
'applies': 0.16; 'call,': 0.16; 'characters.': 0.16; 'count.':
0.16; 'decimal': 0.16; 'efficiently': 0.16; 'fonts,': 0.16;
'humans': 0.16; 'indeed': 0.16; 'noting': 0.16; 'specify': 0.16;
'url:urldefense': 0.16; 'url:v3': 0.16; 'ways.': 0.16; 'wrapper':
0.16; 'wrote:': 0.16; 'python': 0.16; 'subject:question': 0.17;
'feb': 0.17; 'calls': 0.19; 'to:addr:python-list': 0.20; 'doubt':
0.22; 'returns': 0.22; 'sat,': 0.22; 'lines': 0.23; 'to:name
:python-list@python.org': 0.24; 'anything': 0.25; 'skip:- 10':
0.25; 'url:listinfo': 0.25; 'space': 0.26; '11,': 0.26; 'again,':
0.26; 'friday,': 0.26; 'opening': 0.26; 'received:edu': 0.26;
'else': 0.27; 'function': 0.27; 'done': 0.28; 'chris': 0.28;
'mostly': 0.28; 'output': 0.28; 'settings': 0.28; 'email
addr:python.org&gt;': 0.28; 'example,': 0.28; 'printed': 0.28;
'this?': 0.29; 'asked': 0.29; 'takes': 0.31; 'putting': 0.31;
'program': 0.31; 'question': 0.32; 'assume': 0.32; 'concerned':
0.32; 'context': 0.32; 'objects': 0.32; 'python-list': 0.32;
'zero': 0.32; 'but': 0.32; 'there': 0.33; 'someone': 0.34; 'able':
0.34; 'package': 0.34; 'printing': 0.34; 'header:In-Reply-To:1':
0.34; 'trying': 0.35; 'particularly': 0.35; 'request': 0.35;
'cases': 0.36; 'display': 0.36; 'functions': 0.36;
'header:Received:8': 0.36; 'people': 0.36; 'received:filterd':
0.37; 'received:pps.filterd': 0.37; 'really': 0.37; "it's": 0.37;
'others': 0.37; 'though': 0.37; 'url-ip:13.107/16': 0.38; 'way':
0.38; 'quite': 0.39; 'text': 0.39; 'date:': 0.39; 'list': 0.39;
'10,': 0.61; 'here.': 0.61; 'from:': 0.62; 'to:': 0.62; 'format':
0.62; 'job.': 0.62; 'lower': 0.62; 'email addr:gmail.com': 0.63;
'skip:b 20': 0.63; 'skip:b 10': 0.63; 'imagine': 0.64; 're:':
0.64; 'your': 0.64; 'parts': 0.65; 'let': 0.66; 'url-
ip:104.18/16': 0.67; 'accept': 0.67; 'away': 0.67; 'and,': 0.69;
'small,': 0.69; 'track,': 0.69; 'url-ip:52.6/16': 0.69; 'varying':
0.69; 'longer': 0.71; "you'll": 0.73; 'clicking': 0.76;
'formatting': 0.76; 'mode,': 0.76; 'sent:': 0.78; 'discuss': 0.78;
'field': 0.78; 'links.': 0.81; 'attention:': 0.84; 'besides,':
0.84; 'characters': 0.84; 'converted': 0.84; 'email name:&lt
;python-list': 0.84; 'levels.': 0.84; 'say,': 0.84; 'skip:& 50':
0.84; 'transferred,': 0.84; 'creatures': 0.91; 'width': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uchc.edu;
h=from : to : subject :
date : message-id : references : in-reply-to : content-type :
mime-version; s=UCHC03162020;
bh=geGhbVkh9qA97/EybI7Imoc2l9KWydkIK1cAA3/sDZY=;
b=JP05YK4zbRCuIIYsnH84O2hQooPPZC3rQbSfE3YshNtYYrMd7ceiuC8D2EZJWiif5PiQ
sjn6tW27TdbVDhYpTi5xrOu8PTMWShyZE8c+Luic4LN4r7iD1tj06BHHAyqKNlLBmJk0
KrL+Eann44IgvxYCgUd8RpKoQGMY4XK++SQ30Ul+30CCOtYUUKc/zbxiZbUScpzf3wJS
f/EsEi7R7mTHgzHRABpPkuZBgn6CdfKiYY1BrDj9367BAiX+wRqt4dEA+JVqXpheZscP
twUCONsPdSlrwXbkBzQLxO00kLicXEzi/4ISQfZBnEvXSW0PBKBmBEnkq7GWuU4LZKrB FQ==
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
b=E7+vHZfRf9HZcsmVjXBWqVwTYy1gvV6fCDyXPuj3hpj15FvFJbSCJ7Fp7jWZhadp9UoDhHH07W5S09zh1VCI1b56GCUEbn5wcZWhg9sl1lCRq4tAknLjO6RR3TJQXnKZ+kDj8Do2Nmbpg4L4eS6r+bfliuWpxhCnSVrkc+NVoMZEfg/QoZl/pcMWXEcf38BxzFQ9P19ea5POzVOLwKP32mpFyogxPkFXTnTePdT5GvNneEqjmpy9/2mRLpMagbkqZcL0Qv12YtV0wSbXEepKNPF9wAyXGSvJnhVueIXLUhPM4mukq2ilyz3w6lpwUCfBv8SY73k2RBGaEXCLv2Uv3g==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;
s=arcselector9901;
h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;
bh=geGhbVkh9qA97/EybI7Imoc2l9KWydkIK1cAA3/sDZY=;
b=bGhClwbYFvdBkJjpN54bdaFNO+Ef0+AD1Xrlxy+2Kf+edFw4n/JpDWEqryrBZpzK2cdLoUi2msB4nHRtzqyVKlbiDtyJJ5rzwSvgISPsCL94qDHGfjZng9Xf/dSfcwneE9KOlkIwng9EylFOQoHJecnFP4stxdMxONGcbNPNJoOlXccHo3fNIg7gk35dbbd4pAHY+SLRF3kutVQzG0wBw5OzNVGrQfX7H4bN7TsG0yBupDEcmqv534nbNaemwb9QuuHhIagM52AvZJnWTYbyt7llbX/UcJHUc6Sxes7DfAPqok4VI8ebGVTiOAxP4gvTlcFx0c2euQiMYGDZWBcJuA==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass
smtp.mailfrom=uchc.edu; dmarc=pass action=none header.from=uchc.edu;
dkim=pass header.d=uchc.edu; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uchc.onmicrosoft.com;
s=selector2-uchc-onmicrosoft-com;
h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
bh=geGhbVkh9qA97/EybI7Imoc2l9KWydkIK1cAA3/sDZY=;
b=jgXbxyJd81ICROuJUxIaDaXGVnG+4OUcdJf4uP3Z1/+i6gPlSH3AaCOs53duICnbotjz5P3g446FfgCMyhgAeO1C1/FK1GkqOlTZqjG3wBcOU/1NfPdhCDSXcIA9QxyFRshFGxyegvCFuiH9H79ejX+Bm/8+jXd+d1GlRLlFwXs=
Thread-Topic: evaluation question
Thread-Index: AQHZMrHiYnad1aDqLkyUEfoL146TH66zv/cAgAJboBmAAE3UgIAAwjHQgBGDRICAABl/AIAABw6AgAAW7wCABC/qkg==
In-Reply-To: <003501d93da5$e0b00330$a2100990$@gmail.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
x-ms-publictraffictype: Email
x-ms-traffictypediagnostic: SJ0PR14MB5864:EE_|BY5PR14MB4180:EE_
x-ms-office365-filtering-correlation-id: a4f9fa96-59e4-47ff-e594-08db0dd52ca6
x-ms-exchange-senderadcheck: 1
x-ms-exchange-antispam-relay: 0
x-microsoft-antispam: BCL:0;
x-microsoft-antispam-message-info: FK6nwMpWVEJEfqvYFsbRaOd7MJYamxcpa/r46Xx2aDoqoZ+tkgZepWX5fflX8ftn5hH8c7xqTKKrS/a2c3RqVC1sWauaSemUsjNENW1PO1L3/YuOqCiMskgmiShzm4RY6tUn6cyVekrl1jFhTqC87iIgGotc3lmptkEICzHHt1MEk/7U7I1L5n29sLri+yjsvN4fmqFiv84B9RgSy75XGAbD4pHYgqLS0m+C9nSBOjxurMR0tzL9Q1w2hRF9YpI7jDSqxqpBhdAHhK50tUUIwIC2oHO7TMNJpFgb8S9UbxYoZQMduEgs0IYvL6PGzgbURT/J8+0bv+fv0L2jFto98QuECln0wlcVxoNHUPM+hkM+PD4l3eFnNzWRU0XbHvosish3w4ilypYeGf+MDDf2kRxiWEJujnveyGvFczrebnHBltgKNIi4mo9dCcbjArkSY6vjBhpk76GRkrY7S7ncGLQjElrW1Aa5rprVOYwlYpn/GhCfxsUiZzy5a+8DcgPSHjdS4qWAvzXFnB2pYTko7nyhaTXl+tfvpO4KMTDbsFjHZt/dIqJmGvH8MUw55A3gGfRPTIZmDgicRcTLLzDhWZp4De4Bmu3iHJxq1/8EO6+23EwGWcQTPOjCvLvPCH/ZFEfmp9eUxKWImYUqvRyudfqEEeeYcJJt2rWbzz7pq4+LUMCk/TAdCvngxORjbyD61rbIVnhmnNEzY3gFFm8hvYcwtgGdVmRExKof8xgWJzA=
x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:;
IPV:NLI; SFV:NSPM; H:SJ0PR14MB5864.namprd14.prod.outlook.com; PTR:; CAT:NONE;
SFS:(13230025)(4636009)(39840400004)(376002)(366004)(396003)(346002)(136003)(451199018)(66446008)(64756008)(66476007)(66556008)(66946007)(6916009)(83380400001)(91956017)(76116006)(8676002)(41300700001)(786003)(316002)(52536014)(7116003)(8936002)(7696005)(75432002)(3480700007)(166002)(2906002)(71200400001)(33656002)(55016003)(5660300002)(966005)(26005)(186003)(478600001)(6506007)(53546011)(38070700005)(41320700001)(86362001)(38100700002)(9686003)(122000001);
DIR:OUT; SFP:1101;
x-ms-exchange-antispam-messagedata-chunkcount: 1
x-ms-exchange-antispam-messagedata-0: /RYjTY6NN9q/E4aV1n3Vq0l8L4u/AE+hXLByXK1DpFQxLl6CAqwJy4BJ
sJtEf/rc7yXV7oJ7hkmRXoC8aUIVF+HF/JTfq+hMtVrCwgBgl8WErkoX
eJ1FWfWbVYxvUoE0sh01IziTkKqwWOuyC3bFXdZ/uwfTXhS5pCYrh31u
sky7N9HR3x7+jej6IU+V6Zv+9Y8FVncn6bXj0BbfQWj5TFfWK9glTbrW
hgj9Lr4lxar4/Tn4sT1qEwBQ4dDw4oIFqbjzR9EDpDZCnvdbaO7f7lBs
u2kBuxWG9+FcgsSkpsjp7LsDxzGJKrp+0ZRaLmFfnESHW23xNsnRKuxM
YUKbRtlWLIlllYPEmFS3ZSKyMzEE5lJAbksfR1GsO32AQFxZ4zykQeB+
drzSPi7zxJyd6Ay++VWrf8Drp/ufMS9CGJWJL3jWmHiFTBfcMYL+rFKj
Af26wTszSgodDjRYAZsatlubD/GMMlaqsjVh7OXZWLa42TKF9WbF4Fif
uo9jTzwkuATIY62RZCjT+2CGfWQXDKI6XDGbNzRefRHhpuJoVWLeeIO8
3KIyeMM/M6L8BEcxLmV3H+dWb2RHoY4b5TxL9/huI+tMtkVxB8zgP7mS
YmSjtxrE149H0GpD6SUzzqWCMRURPRQiwETwAs7eWtEN9055NQ8+xIzY
8HzBDHXgb+kflh9P/6yBnyirwE2nQja+Bkg0dPxxNBpBYbh1DrtFEeW+
t4O+aPtHVfA78I3O4DG3g/3DGb2KFa4GbKHPK2YcPgY7rnHX9Hi9lZwM
DAg77F3G8knnOM3w3jF0Qvft7HLmfD3ySr7yesTlWbDYcWMZ4ycZEVd4
OKKNhzvA/NyPD2xYpp/RkiE5qL+1wK5lc9Ll5DntVg6vOu+wcCOpf5n5
nfRd7ApQw4WRGHSF1fgjJioNlV5baRMmfIhAo7eecnOCRGeaXgRGPvjO
fKkyjwbcdwrs7AqFvbysdDPPtOUq6ngoqSL5vZ0pJCYsKku7ldn3rDso
hJrLfi0HXnu8uoBjN6oEPlmId706kqV3r99Nti28WBTK/R+pSGAbuiMh
BIaTIPnV1+uay354L08wapmjwoVzZD5+AlsUN7Jk/KyHf9mXR4GxoCJo
dMJ0wAdLa8ZE0JMCaLL1lQesX5pfxt5hedO7u7W/mcAbe+iw2Eum9TJW
+Ug8dv+ORoU5BglNTDjseDAnEXR2nzMcAC6sthj+rZE6/7maMcu2UI4b
MrVvwYN0J36oM5afN2qf9gcIfMVRI7Qu0x0fFwKtbzUQ9a/FL1OTccL7
lfAdhQKZvgNalZ3LSPTlkc0w57vX0QQ8ekCJFMasOjyvm871phmKmaDM
d4yqySqsx832m32RzRnVQRBPg9agEEOlV+eNl9TrStCjbvgfsRiyGbHU
6FYvMNQRaD6+Ig1h47pUOi19TfHbFrRAZILFhPukihn63RS5MtVt6Tgm
Wh34oM0Z7eAkcHDg/SdCalxTQ18sjHW4OoCd/ifQm0iv6JwgyW68nzeB
/us3v1gsW2Cujwzg3rgiz2X34RPxa0mqiaHNtFPKfyQ9Kc1EqayNa411
7zf1610WBjJSRroUb90EXy889JkSDyewHfGk8Xc63nxz9ALdEfQdQw
==
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: SJ0PR14MB5864.namprd14.prod.outlook.com
X-MS-Exchange-CrossTenant-Network-Message-Id: a4f9fa96-59e4-47ff-e594-08db0dd52ca6
X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Feb 2023 15:15:43.0762 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 5c82d83a-818a-4c16-b540-ded2344a7ad3
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: 6DWIDfAa3nbZZf2E6r69vK7xvQU1bxH+g3ncbgWMk8gJDpuja7FMrh1Zv8M7hbJo7bUadYpAYesQyniEQBzRWQ==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR14MB4180
X-Proofpoint-GUID: Uwa-HQSHEkoPKUxAwggBL2sh1XzMbAUs
X-Proofpoint-ORIG-GUID: Uwa-HQSHEkoPKUxAwggBL2sh1XzMbAUs
X-Proofpoint-Virus-Version: vendor=baseguard
engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22
definitions=2023-02-13_09,2023-02-13_01,2023-02-09_01
X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0
impostorscore=0 phishscore=0
bulkscore=0 spamscore=0 malwarescore=0 adultscore=0 clxscore=1015
mlxscore=0 mlxlogscore=999 suspectscore=0 lowpriorityscore=0
priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1
engine=8.12.0-2212070000 definitions=main-2302130138
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: <SJ0PR14MB5864008AC2BC8C0CF96BDC4CB9DD9@SJ0PR14MB5864.namprd14.prod.outlook.com>
X-Mailman-Original-References: <tr0uki$1p2c5$1@dont-email.me>
<Ko8BL.57228$jiuc.57141@fx44.iad>
<slrnttdoeq.s20.elvis-85792@notatla.org.uk>
<bd4ffe68-8c09-b716-9f74-aa2d6abf1705@tompassin.net>
<mailman.1717.1675054683.20444.python-list@python.org>
<tr83bf$381e1$1@dont-email.me> <20230210195907.GC4979@bladeshadow.org>
<CAPTjJmpBhNtpv5kBTu2wCJRV1HLx+ujsZz6QGsASmkW4XbW0yQ@mail.gmail.com>
<20230210215537.GD4979@bladeshadow.org>
<003501d93da5$e0b00330$a2100990$@gmail.com>
 by: Weatherby,Gerard - Mon, 13 Feb 2023 15:15 UTC

“Why are we even still talking about this?”

Because humans are social creatures and some contributors to the list like to discuss things in depth.

From: Python-list <python-list-bounces+gweatherby=uchc.edu@python.org> on behalf of avi.e.gross@gmail.com <avi.e.gross@gmail.com>
Date: Friday, February 10, 2023 at 6:19 PM
To: python-list@python.org <python-list@python.org>
Subject: RE: evaluation question
*** Attention: This is an external email. Use caution responding, opening attachments or clicking on links. ***

There are no doubt many situations someone wants to know how long something
will be when printed but often at lower levels.

In variable-width fonts, for example, the number of characters does not
really line up precisely with how many characters. Some encodings use a
varying number of bytes and, again, the width of the output varies.

So for people who want to make 2-D formatted output like tables, or who want
to wrap lines longer than N characters, you more often let some deeper
software accept your data and decide on formatting it internally and either
print it at once, when done calculating, or in the case of some old-style
terminals, use something like the curses package that may use escape
sequences to update the screen more efficiently in various ways.

If someone wants more control over what they print, rather than asking the
print() function to return something that is mostly going to be ignored,
they can do the things others have already suggested here. You can make your
message parts in advance and measure their length or anything else before
you print. Or make a wrapper that does something for you before calling
print, perhaps only for common cases and then returns the length to you
after printing.

I wonder if the next request will be for print() to know what your output
device is and other current settings so it return the width your text takes
up in pixels in the current font/size ...

I add a tidbit that many ways of printing allow you to specify the width you
want something printed in such as you want a floating point value with so
many digits after the decimal point in a zero or space padded field on the
left. So there are ways to calculate in advance for many common cases as to
how long each part will be if you specify it. Besides, I am not really sure
if "print" even knows easily how many characters it is putting out as it
chews away on the many things in your request and calls dunder methods in
objects so they display themselves and so on. I assume it can be made to
keep track, albeit I can imagine printing out an APL program with lots of
overwritten characters where the number of bytes sent is way more than the
number of spaces in the output.

Why are we even still talking about this? The answer to the question of why
print() does not return anything, let alone the number of characters
printed, is BECAUSE.

-----Original Message-----
From: Python-list <python-list-bounces+avi.e.gross=gmail.com@python.org> On
Behalf Of Python
Sent: Friday, February 10, 2023 4:56 PM
To: python-list@python.org
Subject: Re: evaluation question

On Sat, Feb 11, 2023 at 08:30:22AM +1100, Chris Angelico wrote:
> On Sat, 11 Feb 2023 at 07:36, Python <python@bladeshadow.org> wrote:
> > You would do this instead:
> >
> > message = f"{username} has the occupation {job}."
> > message_length = len(message)
> > print(message)
> > print(message_length)
> > ...
> >
>
> It's worth noting WHY output functions often return a byte count. It's
> primarily for use with nonblocking I/O, with something like this:
>
> buffer = b".............."
> buffer = buffer[os.write(fd, buffer):]
>
> It's extremely important to be able to do this sort of thing, but not
> with the print function, which has a quite different job.

I would agree with this only partially. Your case applies to os.write(),
which is essentially just a wrapper around the write() system call, which
has that sort of property... though it applies also to I/O in blocking mode,
particularly on network sockets, where the number of bytes you asked to
write (or read) may not all have been transferred, necessitating trying in a
loop.

However, Python's print() function is more analogous to C's printf(), which
returns the number of characters converted for an entirely different
reason... It's precisely so that you'll know what the length of the string
that was converted is. This is most useful with the
*snprintf() variants where you're actually concerned about overrunning the
buffer you've provided for the output string, so you can realloc() the
buffer if it was indeed too small, but it is also useful in the context of,
say, a routine to format text according to the size of your terminal. In
that context it really has nothing to do with blocking I/O or socket
behavior.

--
https://urldefense.com/v3/__https://mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!nyKmKANNzMqWDt2IGH9-Vv63_bioBGOYeokJy5GupmZVZIelplk15rvc_5NNbt6afc9yukh8y5X5mZXDVgr_PhY$<https://urldefense.com/v3/__https:/mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!nyKmKANNzMqWDt2IGH9-Vv63_bioBGOYeokJy5GupmZVZIelplk15rvc_5NNbt6afc9yukh8y5X5mZXDVgr_PhY$>

--
https://urldefense.com/v3/__https://mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!nyKmKANNzMqWDt2IGH9-Vv63_bioBGOYeokJy5GupmZVZIelplk15rvc_5NNbt6afc9yukh8y5X5mZXDVgr_PhY$<https://urldefense.com/v3/__https:/mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!nyKmKANNzMqWDt2IGH9-Vv63_bioBGOYeokJy5GupmZVZIelplk15rvc_5NNbt6afc9yukh8y5X5mZXDVgr_PhY$>

RE: evaluation question

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!hirsch.in-berlin.de!fu-berlin.de!uni-berlin.de!not-for-mail
From:
Newsgroups: comp.lang.python
Subject: RE: evaluation question
Date: Mon, 13 Feb 2023 12:41:16 -0500
Lines: 253
Message-ID: <mailman.1814.1676310082.20444.python-list@python.org>
References: <tr0uki$1p2c5$1@dont-email.me> <Ko8BL.57228$jiuc.57141@fx44.iad>
<slrnttdoeq.s20.elvis-85792@notatla.org.uk>
<bd4ffe68-8c09-b716-9f74-aa2d6abf1705@tompassin.net>
<mailman.1717.1675054683.20444.python-list@python.org>
<tr83bf$381e1$1@dont-email.me> <20230210195907.GC4979@bladeshadow.org>
<CAPTjJmpBhNtpv5kBTu2wCJRV1HLx+ujsZz6QGsASmkW4XbW0yQ@mail.gmail.com>
<20230210215537.GD4979@bladeshadow.org>
<003501d93da5$e0b00330$a2100990$@gmail.com>
<SJ0PR14MB5864008AC2BC8C0CF96BDC4CB9DD9@SJ0PR14MB5864.namprd14.prod.outlook.com>
<004401d93fd2$602dda00$20898e00$@gmail.com>
Mime-Version: 1.0
Content-Type: text/plain;
charset="utf-8"
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de apIHDBQImxVcw4ZsmFxHjgiW/6DoTc65qbjkVpX9d+TQ==
Return-Path: <avi.e.gross@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=bRiVNqXg;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.000
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'generated': 0.03; 'this:':
0.03; 'knows': 0.04; 'stream': 0.04; 'containing': 0.05; 'fairly':
0.05; 'is.': 0.05; "python's": 0.05; 'variable': 0.05; '2023':
0.07; 'exit': 0.07; 'simple.': 0.07; 'spaces': 0.07; 'string':
0.07; 'used.': 0.07; 'angelico': 0.09; 'asynchronous': 0.09;
'blocking': 0.09; 'byte': 0.09; 'can,': 0.09; 'characters,': 0.09;
'deeper': 0.09; 'example.': 0.09; 'floating': 0.09; 'fonts': 0.09;
'insist': 0.09; 'lazy': 0.09; 'paragraph': 0.09; 'received:108':
0.09; 'received:209.85.219': 0.09; 'routine': 0.09; 'situations':
0.09; 'string,': 0.09; 'url:mailman': 0.15; '***': 0.16; '+1100,':
0.16; 'anything,': 0.16; 'apl': 0.16; 'applies': 0.16;
'arguments': 0.16; 'assuming': 0.16; 'augmented': 0.16; 'bugs':
0.16; 'call,': 0.16; 'characters.': 0.16; 'count.': 0.16;
'decimal': 0.16; 'deprecate': 0.16; 'design.': 0.16;
'efficiently': 0.16; 'elsewhere': 0.16; 'enhancing': 0.16;
'evaluating': 0.16; 'fonts,': 0.16; 'humans': 0.16; 'indeed':
0.16; 'introduces': 0.16; 'like.': 0.16; 'longer.': 0.16;
'modules,': 0.16; 'noting': 0.16; 'printed.': 0.16; 'productive.':
0.16; 'reality.': 0.16; 'region.': 0.16; 'releases': 0.16;
'rewrite': 0.16; 'somewhat': 0.16; 'specify': 0.16; 'stuck': 0.16;
'syntactic': 0.16; 'things,': 0.16; 'url:urldefense': 0.16;
'url:v3': 0.16; 'ways.': 0.16; 'wrapper': 0.16; 'yield': 0.16;
'wrote:': 0.16; 'python': 0.16; 'subject:question': 0.17; 'feb':
0.17; 'instead': 0.17; 'message-id:@gmail.com': 0.18; 'uses':
0.19; 'calls': 0.19; 'to:addr:python-list': 0.20; 'language':
0.21; 'languages': 0.22; 'doubt': 0.22; 'focused': 0.22; 'maybe':
0.22; 'purposes': 0.22; 'returns': 0.22; 'sat,': 0.22; 'version':
0.23; 'code': 0.23; 'goal': 0.23; 'lines': 0.23; 'run': 0.23;
'anything': 0.25; 'past': 0.25; 'skip:- 10': 0.25; 'url-
ip:188.166.95.178/32': 0.25; 'url-ip:188.166.95/24': 0.25;
'actual': 0.25; 'examples': 0.25; 'url:listinfo': 0.25; 'hearing':
0.75; 'clicking': 0.76; 'formatting': 0.76; 'handles': 0.76;
'mode,': 0.76; 'sent:': 0.78; 'discuss': 0.78; 'field': 0.78;
'life.': 0.80; 'depth': 0.81; 'links.': 0.81; 'attention:': 0.84;
'besides,': 0.84; 'capture': 0.84; 'characters': 0.84;
'converted': 0.84; 'growth.': 0.84; 'innovative': 0.84;
'legitimate': 0.84; 'levels.': 0.84; 'lose': 0.84; 'motivated':
0.84; 'pointing': 0.84; 'repetitive': 0.84; 'say,': 0.84; 'says,':
0.84; 'spelling': 0.84; 'transactions': 0.84; 'transferred,':
0.84; 'want.': 0.84; '\xe2\x80\x9cwhy': 0.84; 'creatures': 0.91;
'errors,': 0.91; 'grammar': 0.91; 'holds': 0.91; 'largely': 0.91;
'when,': 0.91; 'width': 0.91; 'aspects': 0.93; 'locked': 0.93;
'mind,': 0.93; 'mixed': 0.93; 'goals': 0.96
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=thread-index:content-language:content-transfer-encoding
:mime-version:message-id:date:subject:in-reply-to:references:to:from
:from:to:cc:subject:date:message-id:reply-to;
bh=O8bq94myWg9JBvF1RiCBUwUdaqJsqyCAicn8nngTziw=;
b=bRiVNqXgYvzv70iMSL9OA5NsuH7rzTLY1pCVxCgtaWCMswAgmKXH59BDnZINJPRmSf
3gM3pQGrAD2QBv31kIeWi6+hcuItEhGOzYhAmP6hKhwzvkiTqmgeXhmTDaIuSoauq6PL
+mgr3GdnMX2pLfvGmQN2aw0xMZu5unungEDpIk63AGIm3kyArQLesfMUO7sI1w3/hR01
3rA5fbxF5jiPAzP/eioYlHngrxSf/yqfomAT8oP8OAo+WewoTcPkVNFMQ7g9cAbAdoP4
5iGfHDyperb7Nd39Y4aemEoFnd5pkBVPSPqKtm6fDFuORTiAcNkIZgSMOy5ampAH8SD8
WJPA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=thread-index:content-language:content-transfer-encoding
:mime-version:message-id:date:subject:in-reply-to:references:to:from
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
bh=O8bq94myWg9JBvF1RiCBUwUdaqJsqyCAicn8nngTziw=;
b=GX71ZFSiIIkH6IUfWv/pjtFfYBa6fmxiw0Dkrg+maOnzODWiNiKHUvK3vk84yl5owF
17+xPMy0PL2lFiB/FL1nQLhyWjd9z4oO7sddfMOaG40y0i4kbC58BNQi7xrC9qd4otPS
vnLDX38SZZswUkJbhrY3Uv2e2v5wu9zVxy32bDwDFmUOE3FZY9M+2SUm5bQLpkyREwZZ
E6INR7e8HOtwuxkGUp1aWZJJNVzDnU+MzS+J5nCIoyNKy6FvMZGvIYCftnx/uOsiLAAa
ccRCMjmEvh3tiZb9X3MDLTYutgBrO4fmtEf+r0KXCX87azVy4sLFLsUsNnoE9yO/OfMA
8y8g==
X-Gm-Message-State: AO0yUKVXYdgGKDWUF4qZYD4RKG5252LANLV3pzndGz0TPg8WxM7dW8WO
IzDUeLNRLwb3RXfx0zYnW3GrlCcltiE=
X-Google-Smtp-Source: AK7set+y3MZNjexkauHktS1gykNgG3/d2ubi6mgorHe4a8JjAk635kxlv83GltyXfwj77rmAEzOLfA==
X-Received: by 2002:ad4:5ae3:0:b0:56e:a899:1605 with SMTP id
c3-20020ad45ae3000000b0056ea8991605mr12507318qvh.0.1676310079810;
Mon, 13 Feb 2023 09:41:19 -0800 (PST)
In-Reply-To: <SJ0PR14MB5864008AC2BC8C0CF96BDC4CB9DD9@SJ0PR14MB5864.namprd14.prod.outlook.com>
X-Mailer: Microsoft Outlook 16.0
Content-Language: en-us
Thread-Index: AQJBjeeZndWAK5y41s73pA9LvyXagQEV1S1DAqSKeDACXv8iAAJcdE9hAqvJZV8B1urwdQHo9Q2cAtyyCAsCHKa58ALJPJAPrUdbryA=
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: <004401d93fd2$602dda00$20898e00$@gmail.com>
X-Mailman-Original-References: <tr0uki$1p2c5$1@dont-email.me>
<Ko8BL.57228$jiuc.57141@fx44.iad> <slrnttdoeq.s20.elvis-85792@notatla.org.uk>
<bd4ffe68-8c09-b716-9f74-aa2d6abf1705@tompassin.net>
<mailman.1717.1675054683.20444.python-list@python.org>
<tr83bf$381e1$1@dont-email.me> <20230210195907.GC4979@bladeshadow.org>
<CAPTjJmpBhNtpv5kBTu2wCJRV1HLx+ujsZz6QGsASmkW4XbW0yQ@mail.gmail.com>
<20230210215537.GD4979@bladeshadow.org>
<003501d93da5$e0b00330$a2100990$@gmail.com>
<SJ0PR14MB5864008AC2BC8C0CF96BDC4CB9DD9@SJ0PR14MB5864.namprd14.prod.outlook.com>
 by: - Mon, 13 Feb 2023 17:41 UTC

Weatherby,

Of course you are right and people can, and do, discuss whatever they feel like.

My question is a bit more about asking if I am missing something here as my personal view is that we are not really exploring in more depth or breadth and are getting fairly repetitive as if in a typical SF time loop. How does one break out?

Languages often change and people do come and go so some topics can often be re-opened. This though is a somewhat focused forum and it is legitimate to ask if a conversation might best be taken elsewhere for now. The main focus is, at least in theory, aspects of python and mostly about the core as compared to very specific modules, let alone those nobody here has ever even used. Within that, it is fair at times to compare something in python to other languages or ask about perceived bugs or about possible future enhancements. We could discuss if "YIELD FROM" is just syntactic sugar as it often can be done with just the naked YIELD statement, or whether it really allows you to do innovative things, as an example.

But I think where this conversation has gone is fairly simple. The question was why print() does not return the number of characters printed. The answers boiled down to that this was not the design chosen and is mostly consistent with how python handles similar functions that return nothing when the change is largely "internal" in a sense. In addition, plenty of us have suggested alternate ways to get what the OP asked for, and also pointed out there are other things that someone may have wanted instead or in addition, including the actual number of bytes generated for encodings other than vanilla ASCII, or pixels if the text was rendered on a screen using variable width fonts and so on.

Some of the above already counted, in my mind, as adding depth or breadth to the original question. But if the conversation degrades to two or more sides largely talking past each other and not accepting what the other says, then perhaps a natural ending point has been reached. Call it a draw, albeit maybe a forfeit.

So, as part of my process, I am now stuck on hearing many questions as valid and others as not productive. I don't mean just here, but in many areas of my life. The answer is that historically, and in other ways, python took a specific path. Others took other paths. But once locked into this path, you run into goals of trying to remain consistent and not have new releases break older software or at least take time to deprecate it and give people time to adjust.

I have seen huge growing pains due to growth. An example is languages that have added features, such as promises and their variants and used them for many purposes such as allowing asynchronous execution using multiple methods or evaluating things in a more lazy way so they are done just in time. Some end up with some simple function call being augmented with quite a few additional functions with slightly different names and often different arguments and ways they are called that mostly should no longer be mixed with other variants of the function. You need compatibility with the old while allowing the new and then the newer and newest.

Had the language been built anew from scratch, it might be simpler and also more complex, as they would skip the older versions and pretty much use the shinier new version all the time, even as it often introduces many costs where they are not needed.

So it can be very valid to ask questions as long as you also LISTEN to the answers and try to accept them as aspects of reality. Yes, python could have had a different design and perhaps someday may have a different design. But that is not happening TODAY so for today, accept what is and accept advice on how you might get something like what you want when, and if, you need it. The goal often is to get the job done, not to do it the way you insist it has to be done.

At some point, unless someone has more to say with some new twist, it does become a bit annoying.

So let me say something slightly new now. I have been reading about interesting uses of the python WITH statement and how it works. Some of the examples are creating an object with dunder methods that get invoked on entry and exit that can do all kinds of things. One is the ability to modify a list in a way that can be rolled back if there is an error and it is quite simple. You make a copy of the original list on entry. Things are then done to the copy. And if you exit properly, you copy the modified list back on top of the original list. Errors that result simply unwind the serious of transactions by leaving the original list untouched.

Another example has your output stream redirected within the WITH and then put back in place after. What this allows, among many things, is for everything printed to be desrever. Now clearly, such a technique could also be used to capture what is going to be printed, and count how many bytes or characters it produced and make the result available after you exit the region. Heck, if fed a paragraph of text, it could not only print it but create one or more objects containing a detailed analysis including guessing what language it is in, translating it to English, pointing out spelling and grammar errors, and mailing you a copy! You can imagine quite a few side effects of calling print() but again, why would you put the functionality within print() versus in a function you wrote that does all that as well as calling print()?

But even assuming you code that properly and rewrite all your code as something like:

with capture:
print(...)

# use chars_written_within_width as a variable created within that holds what you want.

Is that really any better than several other ways we have suggested would work such as creating an f-string independently and then printing it which would handle quite a few use cases?

If others wish to keep debating this topic or enhancing it, fine. I am not judging but simply expressing the personal opinion that even if I might have more to add, I am not motivated to do so any longer. Then again, I may soon lose the motivation to be part of this forum and take up other hobbies 😉

-----Original Message-----
From: Python-list <python-list-bounces+avi.e.gross=gmail.com@python.org> On Behalf Of Weatherby,Gerard
Sent: Monday, February 13, 2023 10:16 AM
To: python-list@python.org
Subject: Re: evaluation question

“Why are we even still talking about this?”

Because humans are social creatures and some contributors to the list like to discuss things in depth.

From: Python-list <python-list-bounces+gweatherby=uchc.edu@python.org> on behalf of avi.e.gross@gmail.com <avi.e.gross@gmail.com>
Date: Friday, February 10, 2023 at 6:19 PM
To: python-list@python.org <python-list@python.org>
Subject: RE: evaluation question
*** Attention: This is an external email. Use caution responding, opening attachments or clicking on links. ***

There are no doubt many situations someone wants to know how long something will be when printed but often at lower levels.

In variable-width fonts, for example, the number of characters does not really line up precisely with how many characters. Some encodings use a varying number of bytes and, again, the width of the output varies.

So for people who want to make 2-D formatted output like tables, or who want to wrap lines longer than N characters, you more often let some deeper software accept your data and decide on formatting it internally and either print it at once, when done calculating, or in the case of some old-style terminals, use something like the curses package that may use escape sequences to update the screen more efficiently in various ways.

If someone wants more control over what they print, rather than asking the
print() function to return something that is mostly going to be ignored, they can do the things others have already suggested here. You can make your message parts in advance and measure their length or anything else before you print. Or make a wrapper that does something for you before calling print, perhaps only for common cases and then returns the length to you after printing.

I wonder if the next request will be for print() to know what your output device is and other current settings so it return the width your text takes up in pixels in the current font/size ...

I add a tidbit that many ways of printing allow you to specify the width you want something printed in such as you want a floating point value with so many digits after the decimal point in a zero or space padded field on the left. So there are ways to calculate in advance for many common cases as to how long each part will be if you specify it. Besides, I am not really sure if "print" even knows easily how many characters it is putting out as it chews away on the many things in your request and calls dunder methods in objects so they display themselves and so on. I assume it can be made to keep track, albeit I can imagine printing out an APL program with lots of overwritten characters where the number of bytes sent is way more than the number of spaces in the output.

Why are we even still talking about this? The answer to the question of why
print() does not return anything, let alone the number of characters printed, is BECAUSE.

-----Original Message-----
From: Python-list <python-list-bounces+avi.e.gross=gmail.com@python.org> On Behalf Of Python
Sent: Friday, February 10, 2023 4:56 PM
To: python-list@python.org
Subject: Re: evaluation question

On Sat, Feb 11, 2023 at 08:30:22AM +1100, Chris Angelico wrote:
> On Sat, 11 Feb 2023 at 07:36, Python <python@bladeshadow.org> wrote:
> > You would do this instead:
> >
> > message = f"{username} has the occupation {job}."
> > message_length = len(message)
> > print(message)
> > print(message_length)
> > ...
> >
>
> It's worth noting WHY output functions often return a byte count. It's
> primarily for use with nonblocking I/O, with something like this:
>
> buffer = b".............."
> buffer = buffer[os.write(fd, buffer):]
>
> It's extremely important to be able to do this sort of thing, but not
> with the print function, which has a quite different job.


Click here to read the complete article
Pages:1234
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor