Estou tentando depurar (reescrever?) o aplicativo web Python/cherrypy de outra pessoa e me deparei com a seguinte instrução 'if':
if not filename.endswith(".dat") and (
filename.endswith(".dat") or not filename.endswith(".cup")
):
raise RuntimeError(
"Waypoint file {} has an unsupported format.".format(
waypoint_file.filename
)
)
Acho que isso é o mesmo que:
if not A and (A or not B):
Se sim, então:
se
A = False
, então reduz-se aif True and (False or not B):
if True and not B
=not B
se
A = True
, então reduz paraif False:
ou seja, oif
bloco nunca será executado
Tenho quase certeza de que a intenção do if
bloco é avisar o usuário que a extensão do arquivo em questão não é .DAT
nem .CUP
, mas não me parece que ele realmente execute essa intenção.
Acho que o if
bloco deveria ser:
if(not .DAT and not .CUP) = if not(.DAT or .CUP)
Isso está correto?