[Tutor] Engarde program was: i++

scott slewin at rogers.com
Wed Jun 6 23:17:13 CEST 2007


Danny Yoo wrote:
> Double check the definition of mfile_read().  It has a possible type 
> error in terms of the values it returns back to the user.
Oh, I see.  I forgot to change the "if file does not exist part" when i 
changed the other half.  I have changed it and is seems to work when 
there is no file.

#################################################
def mfile_read():
     '''This will open the master file and load all the variables'''
     try:
         mfile = open("./Master/mfile", "r")
     except:
         mfile = open("./Master/mfile", "w")
         mfile.close()
         print "File could not be opened, so I created one"
         master = Master_stats(1631, 8)
         return master

     master = cPickle.load(mfile)
     mfile.close()
     return master
##################################################

-- 
Your friend,
Scott

Sent to you from a Linux computer using Kubuntu Version 7.04 (Feisty Fawn)


More information about the Tutor mailing list