Variable passing to external program - How??

Diez B. Roggisch deets_noospaam at web.de
Sat Oct 11 08:00:40 EDT 2003


> FileLoc = os.path.exists('/home/rigga')

This yields true or false, depending on the existence of "/home/rigga"
I'm guessing now, but what you want is this:

FileLoc = "/home/rigga"
if os.path.exists(FileLoc):
  ....

> if (FileLoc):
>         print "File location exists:"
>         AccFlag = os.access('% FileLoc',os.R_OK | os.X_OK | os.W_OK)

Guessing again - you want to check your perms on that FileLoc of yours - so
why don't you just pass it into the function?
         AccFlag = os.access(FileLoc,os.R_OK | os.X_OK | os.W_OK)

The % operator works similar to printf in C/PHP/Whatever. If you absolutely
want it here, this would work:

>print "%s" % FileLoc
"/home/rigga"


--
Diez




More information about the Python-list mailing list