Variable passing to external program - How??
Rigga
Rigga at noemail.com
Sat Oct 11 11:50:29 EDT 2003
Alex Martelli wrote:
> Rigga wrote:
>
>> Hi,
>>
>> Ok first please bear with me as I am a total Python n00b..
>
> OK, but: the post's subject bears no relation to your code; and
> neither does your text -- you keep talking about an os.system
> call that just isn't there. So, "noob" or not, I'm nonplussed.
>
>> Can anyone explain why this does not like me using % FileLoc in the
>> os.system call???
>
> There is no os.system call in the following code.
>
>> #!/usr/bin/python
>> import sys
>> import os
>> # Check that the folder is accessible and writeable
>> FileLoc = os.path.exists('/home/rigga')
>> if (FileLoc):
>> print "File location exists:"
>> AccFlag = os.access('% FileLoc',os.R_OK | os.X_OK | os.W_OK)
>
> You're checking for a file called '% FileLoc', which does not exist. The
> variable FileLoc at this point is worth True, so you can't possibly want
> to "pass it to an external program" as per subject, either.
>
>> I have full access to the folder I am checking however it always returns
>> no files found (FileLoc = 0) however if I specify the folder I want to
>> test in the os.system call it works fine...
>
> There is no os.system call anywhere in the above.
>
>
> Alex
Alex, point taken I rushed when I was doing this and made many mistakes,
thatll learn me not to rush a post!.
To all the others that replied thanks for your input it has helped me a lot.
What I was going to add to the original post but forgot was how you pass
variables to external programs - hence the title. I have been reading
though the Python Bible however all this variable passing doesnt appear to
work as I would expect i.e.
FilePath = os.path('/home/rigga')
AccFlag = os.access('% FilePath',os.R_OK)
I would expect % FilePath to contain /home/rigga and for os.access to parse
% FilePath in to that and return the results.... however it doesnt, it only
works if I specify the directory in os.access...
Or am I just being stupid?
Cheerz
Rigga
More information about the Python-list
mailing list