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

2007-01-04 Thread Kent Johnson
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 ? os.path.exists() or os.path.isfile() Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mail

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 http://mail.python.org/mailman/listinfo/tut

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: >> > re

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 certai

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') > retu

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 IOE

[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 _