Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

"I take Him shopping with me. I say, 'OK, Jesus, help me find a bargain'" -- Tammy Faye Bakker


devel / comp.lang.python / RE: "Invalid literal for int() with base 10": is it really a literal?

SubjectAuthor
o RE: "Invalid literal for int() with base 10": is it really a literal?<avi.e.gross

1
RE: "Invalid literal for int() with base 10": is it really a literal?

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: <avi.e.gross@gmail.com>
Newsgroups: comp.lang.python
Subject: RE: "Invalid literal for int() with base 10": is it really a literal?
Date: Fri, 26 May 2023 12:22:57 -0400
Lines: 57
Message-ID: <mailman.19.1685118181.23016.python-list@python.org>
References: <582fe74f-9c1d-a6e2-0678-9b171f383c50@roelschroeven.net>
<005901d98fee$555d8140$001883c0$@gmail.com>
Mime-Version: 1.0
Content-Type: text/plain;
charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de trZujpyAXuTpViOx5X1EswqU+DUXpwr4syQ3mLvV3UBA==
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=RajVzECs;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.001
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'message:': 0.03; 'this:':
0.03; 'traceback': 0.04; '(most': 0.05; 'last):': 0.05; '2023':
0.07; '26,': 0.07; 'string': 0.07; 'meant': 0.09; 'reasoning':
0.09; 'received:108': 0.09; 'roel': 0.09; 'schroeven': 0.09;
'valueerror:': 0.09; 'url:mailman': 0.15; 'generates': 0.16;
'it."': 0.16; 'received:mail-qv1-xf34.google.com': 0.16; 'sees':
0.16; 'subject:() ': 0.16; 'subject:: "': 0.16; 'subject:Invalid':
0.16; 'message-id:@gmail.com': 0.18; 'to:addr:python-list': 0.20;
'creates': 0.22; 'science': 0.22; 'code': 0.23; 'skip:- 10': 0.25;
'url-ip:188.166.95.178/32': 0.25; 'url-ip:188.166.95/24': 0.25;
'python,': 0.25; 'url:listinfo': 0.25; 'cannot': 0.25; 'url-
ip:188.166/16': 0.25; 'friday,': 0.26; 'robert': 0.26; 'function':
0.27; '>>>': 0.28; 'thinking': 0.28; 'error': 0.29; 'url-
ip:188/8': 0.31; 'think': 0.32; '"",': 0.32; 'passes': 0.32;
'python-list': 0.32; 'but': 0.32; "i'm": 0.33; 'subject:for':
0.33; 'there': 0.33; 'same': 0.34; 'header:In-Reply-To:1': 0.34;
'received:google.com': 0.34; 'invalid': 0.35; 'runs': 0.35;
'from:addr:gmail.com': 0.35; 'cases': 0.36; 'really': 0.37;
"it's": 0.37; 'file': 0.38; 'way': 0.38; 'means': 0.38; 'use':
0.39; 'base': 0.40; 'something': 0.40; 'provide': 0.60; 'from:':
0.62; 'to:': 0.62; 'love': 0.62; 'subject': 0.63; 'feel': 0.63;
'between': 0.63; 'came': 0.65; 'less': 0.65; 'choose': 0.67;
'order': 0.69; 'sent:': 0.78; '10:': 0.84; 'characters': 0.84;
'clue': 0.84; 'from.': 0.84; 'messages,': 0.84; 'subject:really':
0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20221208; t=1685118178; x=1687710178;
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=x33e6I/ltx8cwYeSB05plPjFuJJJFV98CyLzpvm0kEU=;
b=RajVzECsB/i2suqp32zlyTNRf1osFCFNBXIGN9tRXQkR685huneeAEwWsBqoDlzYS9
6Y1C7hC20GT9Wr2klByYjOv9jtEHXmGxozNE7Of7bHb5GTXCL15I55GB+BwlCxfqqQ35
bSvOg6H9w8c+zVsxcpURyZj8RKnQIzot1Z+1bKMIilPA3AYP8mZ3fBuBmDF4on70MGJG
MiTq4wVC6vo1xeoDducZ1w4e3tzVGR1EnB+bw8FIqFwhvRoxrm65ylMSPl66wE4NydZo
vhev2dNCiJI5Ze9zjXGYVnVfKCfQHLVZo7M9LnaUPSHROQPRno5SSGeOEbYeVOFnRlX3
JQZQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20221208; t=1685118178; x=1687710178;
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=x33e6I/ltx8cwYeSB05plPjFuJJJFV98CyLzpvm0kEU=;
b=fW+w0VlsN4ARcK7OWks7O9iFTB3vPUVAytIYqknCsAc/BwG8qnQofP37XG16YGOUAv
BtIZqwNUBvOdQMs1nn8u5NH3HleyQk1ijBUXQwYiLtXVlZiXVijrl35KUPR5AgTcIPxX
RZ1sIutOLysBbnhWL7OpriCHepF4JKoUl7aFtZeaW4WW5+nJ+6O1mKpWP2WuLTM5Ju7b
7Sw2HhRZndq1/vY7GObNPrC89kOT4jrSyeCf5DjZIbuySNNi7IcIhoc5Kc8jKqn6lTOF
caIWb9XMgLNvBmF+Kb0Zq2M2UmsKr+6Aso7c6gWztMMIq2gBBQaQJfdtbTQWpgjcdK9N
Y7Gg==
X-Gm-Message-State: AC+VfDzX5NjB8AqPrH0eMxjgLGKRyTEAFNkxCo3cOvWnsSFHANVPKcj6
JW/vVY719WslUoFdOspGYQTR1f9AE5U=
X-Google-Smtp-Source: ACHHUZ4HHG6yQrFPYK6npv5C1wkZN8wtDh59GJL0jFCKoMJ3garUtE/U8ezyLsf8lkHP1OybICHn+g==
X-Received: by 2002:ad4:5ce6:0:b0:625:976b:571a with SMTP id
iv6-20020ad45ce6000000b00625976b571amr3053700qvb.34.1685118178588;
Fri, 26 May 2023 09:22:58 -0700 (PDT)
In-Reply-To: <582fe74f-9c1d-a6e2-0678-9b171f383c50@roelschroeven.net>
X-Mailer: Microsoft Outlook 16.0
Content-Language: en-us
Thread-Index: AQMNwT+Q/ZD7HqJ6vIO32lPGQcdYja0EWOxg
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: <005901d98fee$555d8140$001883c0$@gmail.com>
X-Mailman-Original-References: <582fe74f-9c1d-a6e2-0678-9b171f383c50@roelschroeven.net>
 by: <avi.e.gross@gmail.com> - Fri, 26 May 2023 16:22 UTC

Roel,

In order for the code to provide different error messages, it needs a way to differentiate between circumstances.

As far as the int() function is concerned, it sees a string of characters and has no clue where they came from. In Python, int(input()) just runs input() first and creates a string and then passes it along to int().

You can of course argue there are ways to phrase an error message that may be less technicalese.

-----Original Message-----
From: Python-list <python-list-bounces+avi.e.gross=gmail.com@python.org> On Behalf Of Roel Schroeven
Sent: Friday, May 26, 2023 3:55 AM
To: python-list@python.org
Subject: "Invalid literal for int() with base 10": is it really a literal?

Kevin M. Wilson's post "Invalid literal for int() with base 10?" got me
thinking about the use of the word "literal" in that message. Is it
correct to use "literal" in that context? It's correct in something like
this:

>>> int('invalid')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: invalid literal for int() with base 10: 'invalid'

But something like this generates the same message:

>>> int(input())
hello
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: invalid literal for int() with base 10: 'hello'

In cases like this there is no literal in sight.

I'm thinking it would be more correct to use the term 'value' here:
ValueError: invalid value for int() with base 10: 'hello'
Does my reasoning make sense?

--
"I love science, and it pains me to think that to so many are terrified
of the subject or feel that choosing science means you cannot also
choose compassion, or the arts, or be awed by nature. Science is not
meant to cure us of mystery, but to reinvent and reinvigorate it."
-- Robert Sapolsky

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


devel / comp.lang.python / RE: "Invalid literal for int() with base 10": is it really a literal?

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor