check if a file is available

i want my game when at the begining , checks if a file is available then A happens and if the file isn’t avlb . then B happens .

and is there a way to compare , to see if the file size is 2 kilos then do A if not do B

how , please … i’m new to python in GE

import os
if os.stat("file.exe").st_size == 7401472L:
    print "File Size: 7,MB 401,KB 472,BY"
else: print "File wrong size"

This will use the working directory. Use “print os.getcwd()” to get the working directory.

As for checking if a file exists, I’m not sure.

To check if it exists, try this:

    file = open("<the file's location on your computer>", "r")

    # Do the stuff you want it to do with the file here



    # Do this if the file's not there

It tries to open the file in read mode, and if it can’t do that, it goes on the the “except:” bit.

ani & nigo , thanks …