On 23Feb2023 14:58, Hen Hanna <henha...@gmail.com> wrote:
Python's Error-Msg genie (Jeannie) is cute and fickle... She sometimes teases me by not telling me what the VALUE of the "int" is
                        ( "That's for me to know, and for you to find out!" )
as in:
TypeError: can only concatenate str (not "int") to str

This is a runtime error< not a syntax error. Valid code using invalid values. It can only be seen at runtime.

Other times, she (Jeannie)  gives me a helpful comment:
ABCD (above and beyond... her job desc.)
                             if (x=0):
                                   ^^^
SyntaxError: invalid syntax. Maybe you meant '==' or ':=' instead of '='?

Syntax error can be seen at compile time. Since Python's interpreted, the compilation step i usually implicit in trying to run things. But technically this happens before any of _your_ code runs.

The helpfulness of this warning is a _very_ recent upgrade, with Python 3.11 I think, maybe 3.10. The syntax errors used to be a lot less helpful.

is there a Tool that can scan my code and tell me such (wink,wink) type suggestions????

There are several type checking programs for Python, with mypy probably being the best known. I seem to recall seeing some mention of tools which will aid inferring types from partially types programmes, usually as an aid to completing the type annotations.

Cheers,
Cameron Simpson <c...@cskk.id.au>
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to