Traceback (most recent call last):int('invalid')
helloint(input())
However, if you want to change the wording, I'd be more inclined to synchronize it with float():
Traceback (most recent call last):float("a")
File "<stdin>", line 1, in <module>
ValueError: could not convert string to float: 'a'
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:
Traceback (most recent call last):int('invalid')
File "<stdin>", line 1, in <module>
ValueError: invalid literal for int() with base 10: 'invalid'
But something like this generates the same message:
helloint(input())
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?
Traceback (most recent call last):float("a")
On Fri, 26 May 2023 at 17:56, Roel Schroeven <roel@roelschroeven.net> wrote:
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:
Traceback (most recent call last):int('invalid')
File "<stdin>", line 1, in <module>
ValueError: invalid literal for int() with base 10: 'invalid'
But something like this generates the same message:
helloint(input())
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?
It's a ValueError, so the problem is with the value. I suppose
"invalid notation" might work, but since the definition of what's
acceptable to the int() constructor is the same as for a Python
literal, it's not wrong to use that word.
However, if you want to change the wording, I'd be more inclined to synchronize it with float():
Traceback (most recent call last):float("a")
File "<stdin>", line 1, in <module>
ValueError: could not convert string to float: 'a'
34int('y', 36)
Traceback (most recent call last):int('invalid')
helloint(input())
...
However, if you want to change the wording, I'd be more inclined to >synchronize it with float():
Traceback (most recent call last):float("a")
File "<stdin>", line 1, in <module>
ValueError: could not convert string to float: 'a'
Chris Angelico wrote at 2023-5-26 18:29 +1000:
...
However, if you want to change the wording, I'd be more inclined to >synchronize it with float():
+1Traceback (most recent call last):float("a")
File "<stdin>", line 1, in <module>
ValueError: could not convert string to float: 'a'
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 300 |
Nodes: | 16 (2 / 14) |
Uptime: | 62:12:27 |
Calls: | 6,712 |
Files: | 12,244 |
Messages: | 5,355,895 |