[Tutor] Re: os.access(), problems with mode variable

Bernard Lebel python at bernardlebel.com
Tue Aug 17 16:57:02 CEST 2004


Thank you very much Wolfram.

Bernard


----- Original Message -----
From: "Wolfram Kraus" <kraus at hagen-partner.de>
To: <tutor at python.org>
Sent: Tuesday, August 17, 2004 4:42 PM
Subject: [Tutor] Re: os.access(), problems with mode variable


> Heyho!
>
> Bernard Lebel wrote:
> > Hello,
> >
> > Trying to test the existence of a file, using the access function from
the
> > os module.
> > In the documentation it is said to use F_OK as the mode for such thing.
> > However when I run the code below, I get a "NameError: name 'F_OK' is
not
> > defined".
> >
> > Any suggestion?
> >
>
> > import os
> Either add the following line:
> from os import F_OK
>
> >
> > sPath = 'C:\\file.txt'
> >
> > if os.access( sPath, F_OK ) == 1:
> Or change this if statement to:
> if os.access( sPath, os.F_OK ) == 1:
>
> >     print 'yeah!'
> > else:
> >     print 'nah'
> >
> > Thanks in advance
> > Bernard
> >
> HTH,
> Wolfram
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>



More information about the Tutor mailing list