pyutil: fileutil.open_or_create()

This commit is contained in:
Zooko O'Whielacronx 2007-04-17 20:14:26 -07:00
parent e040b85f5d
commit 723f4078a3

View File

@ -178,3 +178,9 @@ def remove_if_possible(f):
remove(f)
except:
pass
def open_or_create(fname, binarymode=True):
try:
return open(fname, binarymode and "r+b" or "r+")
except EnvironmentError:
return open(fname, binarymode and "w+b" or "w+")