JamesDevJim / game-zulu

First game of the coolest project
0 stars 1 forks source link

Catching NameError #12

Open shuttle1987 opened 4 years ago

shuttle1987 commented 4 years ago

https://github.com/JamesDevJim/game-zulu/blob/4b46243499803992d0ef07bb856fb49bb8f72240/shared/control.py#L13-L23

Catching NameError here seems like it couldn't possibly be what we want to be doing here since NameError is an error when Python can't find a name of a variable in the current scope and this particular code doesn't deal with any dynamic variable names. If there somehow was a name error in the first try bloc we will run into it again in the exception handling clause because the code looks identical,

JamesDevJim commented 4 years ago

This is my attempt at getting python to try multiple ports (i.e., '/devttylUSB0') without throwing an error after the first one. I tried using mutilple bare exceptions but python didn't let me so I through in arbitrary exception "NameError".

It did the job! Lol. Not the right way.