[Python-de] Testen, ob Variabel existiert

Diez B. Roggisch deets at web.de
Fre Sep 3 20:28:51 CEST 2004


Kleine Korrektur:

 paths = ["pfad1", "pfad2"]
 prognames = ["prog1", "prog2]

 for progname in prognames:
     found = False
     for path in paths:
         if access(os.path.join(path, progname)):
             Found = True
             break
     if Found:
         print "Found %s at %s" % (progname, path)
     else:
         print "%s not found." % (progname, path)
        

MfG Diez