My python script keeps getting stuck at this point when there is no input: else:
lines = sys.stdin.readlines()
My program has to support no input, so is there a way to figure it if there is no input, so that I just return out of the function. I tried seeing if lines was empty, but the control seems to be lost inside the readlines function (never exits it)
Here is the complete if statement
if len(args) != 0 and args[0] != '-':
# print('B')
input_file = args[0]
try:
f = open(input_file, 'r')
lines = sys.stdin.readlines()
lines = f.close()
except:
return
else:
#print('c')
lines = sys.stdin.readlines()
is there a way to get around this?