Why doesn't Python (error msg) tell me WHAT the actual (arg) values are ?

Hen Hanna henhanna at gmail.com
Thu Feb 23 03:08:31 EST 2023


On Wednesday, February 22, 2023 at 11:57:45 PM UTC-8, Barry wrote:
> > On 23 Feb 2023, at 01:39, Hen Hanna <henh... at gmail.com> wrote:
> > 
> > On Wednesday, February 22, 2023 at 3:46:21 PM UTC-8, 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 (even) 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 
> >                       attempt to call     +      with       'abc',      123       <-------------- 
> > 
> >> i hope that NOW a few of you can see this as a genuine, (reasonable) question. 
> > 
> > Python seems so perfectly User-friendly that 
> > i 'm so curious (puzzled) that it doesn't do the very obvious and easy thing 
> > of giving me this info: 
> > 
> >                         attempt to call     +    with       'abc',       123     <--------------

> It is not easy to do that in a robust and reliable way for any object. 
> You can end up in the code to generate the error message itself breaking. 
> For example using unbounded CPU time when attempting to get the string repr of the variable. 
> 
> Barry 
> 


 Python VM  is seeing an "int" object (123)   (and telling me that)   ...   so it should be easy to print that "int" object 


                What does  Python VM    know ?   and when does it know it ?


it seems like  it is being playful, teasing (or mean),    and   hiding  the ball from me


More information about the Python-list mailing list