Micropython and typing #13711
brianreinhold
started this conversation in
General
Replies: 1 comment 6 replies
-
Careful, you risk starting a flame war with those kind of statements ;-) Splitting a tuple/list/etc out into separate variables is called "unpacking". Type hinting unpacking this way doesn't work in python either, it needs to be declared in a different way. A few suggestions have been made here: https://stackoverflow.com/questions/52082939/type-hints-when-unpacking-a-tuple |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I really dislike the run time typing used by Python, Micropython, and Typescript (and perhaps other languages). When a project becomes large and creates objects with complex fields and structures and has to be understood by someone else, it becomes a nightmare. I don't want to put anyone else through that agony so I strictly type my code.
However, I have run into situations where it appears the typing causes a run time syntax error. For example, this line of code declaring a bunch of variables
conn_handle, start_handle, end_handle, uuid = data
runs fine on the PICO-W. But if I type it
conn_handle: int, start_handle: int, end_handle: int, uuid = data
it gives a syntax error.
Why?
Beta Was this translation helpful? Give feedback.
All reactions