Re: [Tutor] how to know if a file exists

2007-01-04 Thread Vikram Shenoy
Hi, import os if os.path.exists('/path/to/file'): # File exists else: # File doesn't exist It works for files as well as directories. Regards, Vikram U Shenoy ___ Tutor maillist - Tutor@python.org

[Tutor] how to know if a file exists

2007-01-03 Thread shawn bright
hello there, i am writing an app for linux. what command would be easiest to test and see if a certain file exist ? i was going to do something like this try: file = open('/path/to/file', 'rb') return True except: return False but i thought that there would be an easier way. thanks

Re: [Tutor] how to know if a file exists

2007-01-03 Thread Luke Paireepinart
shawn bright wrote: hello there, i am writing an app for linux. what command would be easiest to test and see if a certain file exist ? i was going to do something like this try: file = open('/path/to/file', 'rb') return True except: return False You should except IOError

Re: [Tutor] how to know if a file exists

2007-01-03 Thread Andre Roberge
On 1/4/07, Luke Paireepinart [EMAIL PROTECTED] wrote: shawn bright wrote: hello there, i am writing an app for linux. what command would be easiest to test and see if a certain file exist ? i was going to do something like this try: file = open('/path/to/file', 'rb') return True

Re: [Tutor] how to know if a file exists

2007-01-03 Thread shawn bright
thanks, luke, Andre. appreciate it a lot shawn On 1/3/07, Andre Roberge [EMAIL PROTECTED] wrote: On 1/4/07, Luke Paireepinart [EMAIL PROTECTED] wrote: shawn bright wrote: hello there, i am writing an app for linux. what command would be easiest to test and see if a certain file

Re: [Tutor] how to know if a file exists

2007-01-03 Thread Danny Yoo
On Thu, 4 Jan 2007, Andre Roberge wrote: i am writing an app for linux. what command would be easiest to test and see if a certain file exist ? i was going to do something like this try: file = open('/path/to/file', 'rb') return True except: return False You should