I have some Python program that reads certain values from a file.
File example:
0
4
5
6
The code to parse each line is as follows:
s = f2.readline()
p = int(s)
I am trying to pass sys.maxint in the file instead as follows:
0
sys.maxint
5
6
One of the ways to do so is to check if (s=='sys.maxint') as especial case in the code.
I wonder if there is another neat way to do so?
I am not sure why
ifisn’t “neat”. In my opinion it is the obvious solution. If you really want to do it without anif, you can do this (with an unnecessary string representation):I personally would keep the
if: