by rupe

How do I check for the existence of a file in Python?

Import the module os.path, and call os.path.isfile("filename"). This call will return true if the file exists, and false if it doesn't.

 


 
Read more of   The Yak's Frequently Questioned Answers   (mod.2010-02-10)

429.   why does my 802.11g network seem to die around Uniden 2.4ghz phones?   [jake/2006-05-19]
401.   What is the Fly Over Zone?   [jake/2004-01-28]
398.   How can I fix dhclient in debian stable with the 2.6 kernel?   [leif/2003-12-20]
341.   Can you give me some pointers for using gpg/pgp and other encryption?   [jake/2002-12-19]
307.   Where the hell is #yak?   [vonguard/2002-02-07]
241.   What the hell does [U:a:S:b:h] mean?   [mennonite/2001-06-05]
240.   Where can I find black and white photos of people and places in San Francisco?   [rupe/2001-06-05]
217.   Why must I use NiMH (nickel metal hydride) batteries?   [strick/2001-05-09]
181.   Where does the Yak read?   [rupe/2001-06-05]
172.   What were the specs of the Apollo Guidance Computer (AGC)?   [rupe/2001-02-05] ( strick/2001-02-11 )
138.   How can I become an asshole in five easy steps?   [chota/2000-10-22]
129.   What do all the diferent colors of manic panic hair dye look like?   [jesse/2000-10-07]
121.   What time is it?   [rupe/2000-09-18] ( josh/2001-04-03 strick/2001-03-10 )
117.   Where can I find information on character codes, and encoding issues?   [rupe/2000-09-12]
82.   Can Mice Fly ?   [philbert2k/2000-04-27]
72.   What happens when you smoke weed every day for a year and then quit cold turkey.   [vonguard/2000-04-04]
65.   Where can I get help with my Physics homework?   [strick/2000-02-22]
29.   Where can I find out about the DVD hack?   [strick/2000-02-06]
24.   Why is the ocean blue?   [simon/2000-01-20]
13.   What internet security sites should I read?   [strick/2000-01-17]