1 00:00:01,970 --> 00:00:07,570 One of the common patterns when working with files is to actually put them in a try except block. 2 00:00:08,030 --> 00:00:13,250 So in here we can say try and actually put them. 3 00:00:14,530 --> 00:00:21,610 Like this and try out to see if the file exists so we can say except. 4 00:00:22,990 --> 00:00:23,920 And let's say. 5 00:00:25,090 --> 00:00:29,860 File not found error, which we've seen before. 6 00:00:31,510 --> 00:00:40,450 And here, I can say as air and inside will say, print file does not exist. 7 00:00:41,490 --> 00:00:49,140 So that now if I run this and remember in our current directory, we don't have said dot text if I run 8 00:00:49,140 --> 00:00:49,500 this. 9 00:00:51,690 --> 00:00:57,450 I get an error file does not exist, we can even raise this error if we want to do so, we can say raise 10 00:00:57,990 --> 00:00:58,410 error. 11 00:00:59,460 --> 00:01:01,350 So now it works as expected. 12 00:01:01,530 --> 00:01:06,000 I'll get fouled does not exist and then give a file not found error. 13 00:01:06,980 --> 00:01:11,250 So this is a common way to work with files to handle different errors. 14 00:01:11,690 --> 00:01:13,550 Another common one with. 15 00:01:15,580 --> 00:01:26,440 Philes, is this idea of an IO era and an era usually happens when the computer or the machine you're 16 00:01:26,440 --> 00:01:32,080 on has some issue reading or writing or doing any sort of Eyo operation. 17 00:01:33,200 --> 00:01:41,150 So you can have something like WHIO error in here and raise that er if you want. 18 00:01:42,560 --> 00:01:46,400 Again, if I run this file not found there. 19 00:01:47,520 --> 00:01:51,750 If for some reason I give it a weird mode to do. 20 00:01:53,310 --> 00:01:59,700 I get an unsupported operation or the options are endless, but I hope by now you have an idea of how 21 00:01:59,700 --> 00:02:06,210 to do fall ill, but let's do a fun exercise, because up until now, we haven't really done anything 22 00:02:06,210 --> 00:02:06,690 exciting. 23 00:02:06,690 --> 00:02:10,560 We just read a bunch of text from a file and that was it. 24 00:02:10,740 --> 00:02:13,200 Nothing that creator. 25 00:02:13,260 --> 00:02:13,640 Right. 26 00:02:13,800 --> 00:02:15,090 So let's do something fun. 27 00:02:15,780 --> 00:02:19,990 In the next video, we're going to try and build a translator. 28 00:02:20,580 --> 00:02:21,080 That's right. 29 00:02:21,510 --> 00:02:22,500 I'll see in the next video.