What's the pythonic way to designate unreachable code in python as in:
gender = readFromDB(...) # either 'm' or 'f'
if gender == 'm':
greeting = 'Mr.'
elif gender == 'f':
greeting = 'Ms.'
else:
# What should this line say?
You should just remove the return True line, and instead of print (result) , return result . That will be True if the matrix is square AND symmetric, and False if it's square and NOT symmetric.
In computer programming, unreachable code is part of the source code of a program which can never be executed because there exists no control flow path to the code from the rest of the program.
Any code block that is guarded by a conditional checks for Python 2 will not be analyzed. So while the code block may run on your server, it is treated as unreachable from the perspective of the static code analyzer in Pylance.
raise ValueError('invalid gender %r' % gender)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With