Re: simple way to touch a file if it does not exist

2008-05-22 Thread bukzor
On May 22, 12:07 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Wed, 21 May 2008 17:56:38 -0700, bukzor wrote: > > On May 21, 5:37 pm, Nikhil <[EMAIL PROTECTED]> wrote: > > >> if os.path.exists('file'): > >> open('file', 'w').close() > > >> Right? > > > You only want to blank

Re: simple way to touch a file if it does not exist

2008-05-22 Thread Giampaolo Rodola'
On 22 Mag, 11:54, Ken Starks <[EMAIL PROTECTED]> wrote: > After os.path.exists, you need to check it _is_ a > file, and not a directory. > > > > Giampaolo Rodola' wrote: > > On 22 Mag, 01:15, Nikhil <[EMAIL PROTECTED]> wrote: > >> what are the simple ways? > >> I could think of os.open(), os.exec(t

Re: simple way to touch a file if it does not exist

2008-05-22 Thread Ken Starks
After os.path.exists, you need to check it _is_ a file, and not a directory. Giampaolo Rodola' wrote: On 22 Mag, 01:15, Nikhil <[EMAIL PROTECTED]> wrote: what are the simple ways? I could think of os.open(), os.exec(touch file) are there any simpler methods? Just use os.path.exists to check

Re: simple way to touch a file if it does not exist

2008-05-22 Thread Marc 'BlackJack' Rintsch
On Wed, 21 May 2008 17:56:38 -0700, bukzor wrote: > On May 21, 5:37 pm, Nikhil <[EMAIL PROTECTED]> wrote: > >> if os.path.exists('file'): >> open('file', 'w').close() >> >> Right? > > You only want to blank it if it exists? If it doesn't exist you won't > create it. > The .close() is supe

Re: simple way to touch a file if it does not exist

2008-05-21 Thread bukzor
On May 21, 5:37 pm, Nikhil <[EMAIL PROTECTED]> wrote: > bukzor wrote: > > On May 21, 5:10 pm, "Giampaolo Rodola'" <[EMAIL PROTECTED]> wrote: > >> On 22 Mag, 01:15, Nikhil <[EMAIL PROTECTED]> wrote: > > >>> what are the simple ways? > >>> I could think of os.open(), os.exec(touch file) > >>> are the

Re: simple way to touch a file if it does not exist

2008-05-21 Thread Nikhil
bukzor wrote: On May 21, 5:10 pm, "Giampaolo Rodola'" <[EMAIL PROTECTED]> wrote: On 22 Mag, 01:15, Nikhil <[EMAIL PROTECTED]> wrote: what are the simple ways? I could think of os.open(), os.exec(touch file) are there any simpler methods? Just use os.path.exists to check for file existence and

Re: simple way to touch a file if it does not exist

2008-05-21 Thread bukzor
On May 21, 5:10 pm, "Giampaolo Rodola'" <[EMAIL PROTECTED]> wrote: > On 22 Mag, 01:15, Nikhil <[EMAIL PROTECTED]> wrote: > > > what are the simple ways? > > I could think of os.open(), os.exec(touch file) > > > are there any simpler methods? > > Just use os.path.exists to check for file existence a

Re: simple way to touch a file if it does not exist

2008-05-21 Thread Giampaolo Rodola'
On 22 Mag, 01:15, Nikhil <[EMAIL PROTECTED]> wrote: > what are the simple ways? > I could think of os.open(), os.exec(touch file) > > are there any simpler methods? Just use os.path.exists to check for file existence and open() as replacement for touch. >>> import os >>> if not os.path.exists('fi

simple way to touch a file if it does not exist

2008-05-21 Thread Nikhil
what are the simple ways? I could think of os.open(), os.exec(touch file) are there any simpler methods? -- http://mail.python.org/mailman/listinfo/python-list