[Tutor] Equivalent exception of os.path.exists()
Lie Ryan
lie.1296 at gmail.com
Mon Nov 30 16:24:33 CET 2009
On 12/1/2009 12:00 AM, biboy mendz wrote:
> http://pastebin.ca/1693849
>
> This is end-of-chapter3 exercise of the book Core Python Programming.
>
> I'm reading/searching in the book and other materials but is
> unsuccessful. There are at least 50 exceptions listed but I can't find
> anything close.
>
> I commented out my modified script to just what *should* be applicable.
> Can you please point me to the right direction? TIA.
You're trying to take exception from raw_input(); raw_input() merely
receive input from the stdin. raw_input() doesn't have anything to do
with the file. You should expect the exception to come from the open()
function instead.
However, on a little bit of note; open('...', 'w') will (almost) always
work since if the file doesn't exists, python will simply create it. The
only time it wouldn't work is if you've have file edit permission but
not create new file permission.
More information about the Tutor
mailing list