Re: how do you know if open failed?
- From: Neil Cerutti <horpner@xxxxxxxxx>
- Date: 28 Sep 2006 20:33:49 +0200
On 2006-09-28, SpreadTooThin <bjobrien62@xxxxxxxxx> wrote:
f = open('myfile.bin', 'rb')
How do I know if there was an error opening my file?
Try it an see.
Seriously, it will raise an exception that you can catch.
try:
f = open('myfile.bin', 'rb')
# Do stuff with f
except IOError, inst:
print 'Phooey.', inst.errno, inst.strerror
--
Neil Cerutti
.
- References:
- how do you know if open failed?
- From: SpreadTooThin
- how do you know if open failed?
- Prev by Date: Re: License / Registration key enabled software
- Next by Date: Re: using the email module
- Previous by thread: Re: how do you know if open failed?
- Next by thread: Recursive descent algorithm able to parse Python?
- Index(es):
Relevant Pages
|