On Mon, Mar 21, 2016 at 12:28 PM, Mark Lawrence <breamore...@yahoo.co.uk> wrote:
> I got to line 22, saw the bare except, and promptly gave up.

Oh, keep going, Mark. It gets better.

def readstrfile(file):
    try:
        data=open(file,"r").read()
    except:
        return 0
    return data

def start():
    psource=readstrfile(infile)
    if psource==0:
        print ("Can't open file",infile)
        exit(0)



So, if any exception happens during the reading of the file, it gets
squashed, and 0 is returned - which results in a generic message being
printed, and the program terminating, with return value 0. Awesome!

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to