[Tutor] How to get script to detect whether a file exists?
Richard D. Moores
rdmoores at gmail.com
Tue Aug 3 02:53:50 CEST 2010
On Mon, Aug 2, 2010 at 16:57, Steven D'Aprano <steve at pearwood.info> wrote:
> # File *probably* doesn't exist. Consider better error checking.
Steve, before I dig into your detailed reply, please tell me what you
meant by " # File *probably* doesn't exist. Consider better error
"""Open file given by path if it exists, and return its contents.
If it doesn't exist, save and return the default contents.
f = open(path, 'r')
# File *probably* doesn't exist. Consider better error checking.
data = 
data = pickle.load(f)
More information about the Tutor