best way to check if a file exists?

Gabriel Genellina gagsl-py at
Tue Oct 31 22:32:23 CET 2006

At Tuesday 31/10/2006 18:01, John Salerno wrote:

>What is the best way to check if a file already exists in the current
>directory? I saw os.path.isfile(), but I'm not sure if that does more
>than what I need.

os.access(full_filename, os.F_OK)

>I just want to check if a file of a certain name exists before the user
>creates a new file of that name.

Remember that things may change between you check the name and you 
actually create the file.

Gabriel Genellina
Softlab SRL 

Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! -

More information about the Python-list mailing list