os,access argument problem
Quinn Dunkan
quinn at zloty.ugcs.caltech.edu
Thu Aug 31 05:40:27 EDT 2000
More information about the Python-list mailing list
Thu Aug 31 05:40:27 EDT 2000
- Previous message (by thread): Simple Interpolation in Numpy?
- Next message (by thread): os,access argument problem
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Tue, 22 Aug 2000 07:42:45 CST, Matthew Schinckel <matt at null.net> wrote: >In message <39A02CE2.CFE1BE01 at uniserve.com>, Bob van der Poel 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.... >> > >You might want to try a different method: Or you could just use access() :) F_OK is, as in C, a constant, not a string. if os.access(newfile, os.F_OK): ... Of course, os.path.exists is easier to read and type, so you might as well use that. >try: > file = open(filename,'r') >except IOError: > print "File does not exist" > ># Act on the open file > >file.close() I think the "Act on open file" and file.close() was meant to be inside the try clause here.
- Previous message (by thread): Simple Interpolation in Numpy?
- Next message (by thread): os,access argument problem
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list