Re: Making os.unlink() act like "rm -f"

2010-12-11 Thread Roy Smith
In article , Christian Heimes wrote: > Am 11.12.2010 18:04, schrieb Roy Smith: > > if os.access("file", os.F_OK): > >os.unlink("file") > > > > but that's annoying too. What would people think about a patch to > > os.unlink() to add an optional second parameter which says to ignore > > at

Re: Making os.unlink() act like "rm -f"

2010-12-11 Thread Godson Gera
On Sat, Dec 11, 2010 at 10:34 PM, Roy Smith wrote: > os.unlink("file", ignore=True) > -- > http://mail.python.org/mailman/listinfo/python-list > Take a look at shutil.rmtree http://docs.python.org/library/shutil.html?highlight=shutil#shutil.rmtree -- Thanks & Regards, Godson Gera Python Consu

Re: Making os.unlink() act like "rm -f"

2010-12-11 Thread Nobody
On Sat, 11 Dec 2010 12:04:01 -0500, Roy Smith wrote: > I just wrote an annoying little piece of code: > > try: > os.unlink("file") > except OSError: >pass > > The point being I want to make sure the file is gone, but am not sure if > it exists currently. Essentially, I want to do what "

Re: Making os.unlink() act like "rm -f"

2010-12-11 Thread Christian Heimes
Am 11.12.2010 18:04, schrieb Roy Smith: > if os.access("file", os.F_OK): >os.unlink("file") > > but that's annoying too. What would people think about a patch to > os.unlink() to add an optional second parameter which says to ignore > attempts to remove non-existent files (just like "rm -f"

Making os.unlink() act like "rm -f"

2010-12-11 Thread Roy Smith
I just wrote an annoying little piece of code: try: os.unlink("file") except OSError: pass The point being I want to make sure the file is gone, but am not sure if it exists currently. Essentially, I want to do what "rm -f" does in the unix shell. In fact, what I did doesn't even do th