Re: how do you know if open failed?



SpreadTooThin wrote:

f = open('myfile.bin', 'rb')

How do I know if there was an error opening my file?

you'll notice:

>>> f = open("myfile.bin", "rb")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IOError: [Errno 2] No such file or directory: 'myfile.bin'
>>>

</F>

.