Variable passing to external program - How??

Rigga Rigga at noemail.com
Sat Oct 11 15:22:01 EDT 2003


Christopher Koppler wrote:

> On Sat, 11 Oct 2003 15:22:36 GMT, Christopher Koppler
> <klapotec at chello.at> wrote:
> 
>>On Sat, 11 Oct 2003 16:08:46 +0000, Rigga <Rigga at noemail.com> wrote:
>>
>>>Christopher Koppler wrote:
>>>
>>>> On Sat, 11 Oct 2003 15:50:29 +0000, Rigga <Rigga at noemail.com> wrote:
>>>> 
>>>>>FilePath = os.path('/home/rigga')
>>>>>AccFlag = os.access('% FilePath',os.R_OK)
>>>>>
>>>>>I would expect % FilePath to contain /home/rigga
>>>> 
>>>> Why would you expect that?
>>>
>>>because Ive assigned it using the  FilePath = os.path('/home/rigga') -
>>>surely therefore FilePath contains the value /home/rigga???????
>>
>>Yes, but what do you think that '% FilePath' means? This is an
>>ordinary string, and does not magically expand to the variable's
>>contents, which I assume you wanted. You need to use just the variable
>>name for that:
>>
>>AccFlag = os.access(FilePath, os.R_OK)
>>
>>If you wanted to use the % operator for strings, you could also write
>>that as
>>
>>AccFlag = os.access('%s' % FilePath, os.R_OK)
>>
>>which is completely unnecessary in this case, however.
> 
> And also, I completely overlooked:
> FilePath = os.path('/home/rigga') will not work either, because
> os.path is a _module_ (which is not callable), not a function to
> create paths. Pathnames are just strings, so
> 
> FilePath = '/home/rigga'
> 
> is what you want.
> 
> 
> --
> Christopher
Thank you!! it makes more sense to me now.

Cheers

Rigga




More information about the Python-list mailing list