if
statement can be simplified PYL-R1703118 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
119
120 try:
121 if s.connect_ex(connect_to) == 0:122 return True
123 else:
124 return False
The highlighted if
block can be refactored into a simplified statement, increasing its readability.
def simplifiable_if(arg, arg2):
if arg and not arg2:
var = True
else:
var = False
return var
def simplifiable_if(arg, arg2):
var = bool(arg and not arg2)
return var