Login or Sign Up
Logging in...
Remember me
Log in
Or
Sign Up
Forgot password or user name?
Log in with
Search in titles only
Search in Python only
Search
Advanced Search
Forums
BYTES
Product Launch
Updates
Devops Toolkit
Today's Posts
Member List
Calendar
Home
Forum
Topic
Python
How to check if a file exists?
Collapse
X
Collapse
Posts
Latest Activity
Photos
Page
of
1
Filter
Time
All Time
Today
Last Week
Last Month
Show
All
Discussions only
Photos only
Videos only
Links only
Polls only
Events only
Filtered by:
Clear All
new posts
Previous
template
Next
nick john
New Member
Join Date:
Mar 2011
Posts:
4
#1
How to check if a file exists?
Mar 27 '11, 05:34 PM
I don't want to create the file if it dosen't exist I just want to see if it's there. Like have a variable return True if it is in fact there.
Thanks,
Nick
bvdet
Recognized Expert
Specialist
Join Date:
Oct 2006
Posts:
2851
#2
Mar 27 '11, 06:07 PM
All you need is a path and function call from the
os
module.
Code:
import os path = "X:/subdir/file_name" os.path.isfile(path)
Comment
Post
Cancel
Previous
template
Next
Working...
Yes
No
OK
OK
Cancel
👍
👎
☕
Comment