Let's say i have some code written in Python 2.7 this code relies on one if statement being true and then uses another if condition and another depending on if both end up conditions being true can i continue to do this forever in my code or is there a limit? and is there anyway i can do this any better?
#!/usr/bin/python
import os
if os.path.isfile('/tmp/EXAMPLE.txt'):
if os.path.getsize('/tmp/EXAMPLE.txt') == 0:
if os.access('/tmp/EXAMPLE.txt', os.W_OK) == True:
DATA = open('/tmp/EXAMPLE.txt', 'w')
if DATA.mode == 'w':
DATA.write('DATA')
DATA.close()
DATA = open('/tmp/EXAMPLE.txt', 'r')
if DATA.mode == 'r':
if 'DATA' in DATA.read():
print 'File size is no longer zero'
else:
print 'Data failed to write'
else:
print 'File could not be read from'
else:
print 'File could not written to'
else:
print 'File does not have write permissions'
else:
print 'File has data already'
else:
print 'File does not exist'