-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unhelpful error message #1046
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Consider the following real world example from a novice:
To make the code readable the novice has defined LED_Pin as a nice alias for Pin 0 (there is an LED connected to it)
They are constructing a piece of code that will have multiple LEDs indicating 'stuff', so have defined a function to turn off all of them.
Then they forget they have to call 'write_digital' to access the pin and try to set the pin to True - to turn it on.
Python accepts this as a fine and beautiful line of code....
In the while loop they plan to turn off all the LEDs and then sense the temperature, before turning on the appropriate one.
They get a not helpful error message on the line:
which is caused by their slip on a later line and python dynamically retyping the variable LED_Pin as a bool.
This is a 'feature' of python, fair enough, but it is a hard error to spot and the editor hasnt helped. (I have trimmed the code to just the minimum to illustrate - there was a lot more which made it more hidden).
Possibly indicating a variable has changed type in some way might help.
The text was updated successfully, but these errors were encountered: