os,access argument problem

Bob van der Poel bvdpoel at uniserve.com
Sun Aug 20 20:05:52 EDT 2000


Matthew Dixon Cowles wrote:
> 
> On Sun, 20 Aug 2000 12:09:22 -0700, Bob van der Poel
> <bvdpoel at uniserve.com> wrote:
> >
> >
> >I want to test for the existance of a file, so I:
> >
> >        if os.access(newfile, 'F_OK'):
> >
> >However, I get the error message:
> >
> >       TypeError: illegal argument type for built-in operation
> >
> >Something wrong with the 'F_OK' I presume. Can't figure out what to
> >change it to....
> 
> The symbols listed in the documentation aren't meant to be strings,
> they're constants exported by the module. You want:
> 
> os.access("foo",os.F_OK)
>

Ahh... actually, I'd tried os.access("foo", F_OK) and using a string was
an act of desperation. Never occurred that I'd have to use os.F_OK. I'm
wondering if it makes more sense to 'from os import *', or should I
learn to do it this way?

Thanks!
-- 
   __
  /  )      /         Bob van der Poel
 /--<  ____/__        bvdpoel at uniserve.com
/___/_(_) /_)         http://users.uniserve.com/~bvdpoel



More information about the Python-list mailing list