I've never quite gotten this down. I think what this if statement does is allow a function to be run when it is called and not when the module that it is written in is imported. Take this code for example:
# Finds duplicate values in a specified feature class field and populates those reords with a 'Y' in another field
import arcpy
# enter program inputs
def findDupes(inFeatureClass, checkField, updateField, countRec = 0):
    with arcpy.da.SearchCursor(inFeatureClass, [checkField]) as rows:
        values = [r[0] for r in rows]
    with arcpy.da.UpdateCursor(inFeatureClass, [checkField, updateField]) as rows:
        for row in rows:
            if values.count(row[0]) >= 2:
                row[1] = 'Y2'
                print "yes"
            rows.updateRow(row)
            countRec += 1
            print countRec
if __name__ == '__main__':
    fc = raw_input("paste input feature class path from ArcCatolog: ") 
    fld = raw_input("duplicate field values: ")
    up = raw_input("update field: ")
    findDupes(fc, fld, up)
the module arcpy is irrelevant for this question; however, the way I'm seeing things, if I put the raw inputs at the top of the script it would still run but if I imported the script with this function as a module (import CheckforDupes) it would run upon the import statement instead of when the function was called if the __name__ == "__main__" wasn't there. Is that right?
 
     
    