On 2/22/2023 6:46 PM, Hen Hanna wrote:
On Wednesday, February 22, 2023 at 12:05:34 PM UTC-8, Hen Hanna wrote:
py bug.py
Traceback (most recent call last):
File "C:\Usenet\bug.py", line 5, in <module>
print( a + 12 )
TypeError: can only concatenate str (not "int") to str


Why doesn't Python (error msg) do the obvious thing and tell me
WHAT the actual (offending, arg) values are ?

In many cases, it'd help to know what string the var A had , when the error 
occurred.
------------ i wouldn't have to put print(a) just above, to see.




( pypy doesn't do that either, but Python makes programming (debugging) so easy 
that i hardly feel any inconvenience.)



i  see that my example   would be clearER  with this one-line  change:


                   >  py   bug.py

                    Traceback (most recent call last):

                   File "C:\Usenet\bug.py", line 5, in <module>
                                          map( Func,    fooBar(  X,  Y,  X +  Y 
 ))
TypeError: can only concatenate str (not "int") to str


i hope that   NOW   a few of you  can  see this as a genuine,  (reasonable)  
question.

It tells me to go look at the function definition and how it's being invoked. Even if I knew which of (X, Y) was an int and which a str, I'd still need to do that.

Or you could add type annotations to your code and run mypy on it...


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

Reply via email to