1 00:00:01,140 --> 00:00:07,770 We already talked about how to open a file in the python for reading, for writing, amending, whatever, 2 00:00:07,830 --> 00:00:15,060 OK, and we checked the mods that are available, read, write, read, plus read, write, appending 3 00:00:15,500 --> 00:00:16,710 for bindery and so on. 4 00:00:16,740 --> 00:00:24,770 OK, now what if we want so frequent open and we want to open a file that does not exist actually. 5 00:00:24,780 --> 00:00:29,700 So just three days time, the text we want to open it for. 6 00:00:29,940 --> 00:00:36,300 OK, it's a simple example of actually no worries and I want to print the content of it. 7 00:00:37,080 --> 00:00:39,020 As we learned previously, no big deal. 8 00:00:39,420 --> 00:00:40,050 So read. 9 00:00:41,910 --> 00:00:47,730 And so let's say that actually and check if it's working or not. 10 00:00:47,990 --> 00:00:48,730 It sure did. 11 00:00:48,950 --> 00:00:51,360 As you can see, we don't have this trick here. 12 00:00:52,020 --> 00:00:55,110 So, yeah, no such file or directory. 13 00:00:55,500 --> 00:00:57,530 OK, now how to solve such a thing? 14 00:00:57,540 --> 00:00:59,410 We don't need such a thing. 15 00:00:59,430 --> 00:01:02,570 Actually, this is ugly and this is not impractical. 16 00:01:02,850 --> 00:01:05,550 So we would use the tried and we already saw that. 17 00:01:05,550 --> 00:01:06,120 How to do the. 18 00:01:07,180 --> 00:01:08,640 So try these. 19 00:01:09,010 --> 00:01:11,750 OK, so far, so good, no. 20 00:01:12,430 --> 00:01:13,850 Except this thing. 21 00:01:14,440 --> 00:01:17,140 Now, remember when we bought just accept now. 22 00:01:17,140 --> 00:01:19,540 No, this time we would put another value. 23 00:01:19,900 --> 00:01:28,030 Now we would use something that found it like this, that is capital while not found like this. 24 00:01:28,360 --> 00:01:30,380 So this means that the file is not found. 25 00:01:31,240 --> 00:01:33,200 This is not just an error. 26 00:01:34,120 --> 00:01:36,130 This is a specific error from this error. 27 00:01:36,400 --> 00:01:37,630 Now, why is that? 28 00:01:37,900 --> 00:01:40,540 Because we don't need just an error. 29 00:01:40,540 --> 00:01:42,140 I want I will do this. 30 00:01:42,160 --> 00:01:46,840 No, for example, if the pilot found, I will do a specific thing. 31 00:01:47,830 --> 00:01:53,890 If the file there is errors with the eye, so the fight is existed, but the fight cannot be opened, 32 00:01:53,890 --> 00:01:56,840 for example, I will do another things too. 33 00:01:57,490 --> 00:02:05,230 OK, so if this happened, so I will print Bontempi by not Funt. 34 00:02:05,530 --> 00:02:06,880 OK, so far so good. 35 00:02:07,570 --> 00:02:19,390 Now another exception, except I don't know if there is a high or I or error this time I will print. 36 00:02:20,310 --> 00:02:21,560 Oh I. 37 00:02:21,600 --> 00:02:23,860 Oh I haven't. 38 00:02:25,000 --> 00:02:26,830 OK no whatever. 39 00:02:27,340 --> 00:02:28,110 OK, cool. 40 00:02:29,220 --> 00:02:31,890 Now, let's check this if it is working or not. 41 00:02:32,520 --> 00:02:37,860 This should be printing fine, not fun because the latest three is not fun. 42 00:02:37,890 --> 00:02:40,380 OK, so let's open it, actually. 43 00:02:40,410 --> 00:02:40,740 Yeah. 44 00:02:41,010 --> 00:02:41,450 Yeah. 45 00:02:41,460 --> 00:02:42,360 So far, so good. 46 00:02:43,080 --> 00:02:43,580 It found. 47 00:02:43,830 --> 00:02:45,530 Which means it worked correctly. 48 00:02:45,870 --> 00:02:46,970 So which is better. 49 00:02:46,980 --> 00:02:48,070 Actually this is fun. 50 00:02:48,070 --> 00:02:56,040 Not found with handling the arrow or this is no such viral data and a lot finds a lot of text. 51 00:02:56,190 --> 00:02:58,170 Actually this is actually this is not good. 52 00:02:58,200 --> 00:03:01,730 And by the way, not just that actually this is more practical. 53 00:03:02,040 --> 00:03:06,300 So it's not like printing just a simple file that found. 54 00:03:06,450 --> 00:03:09,390 So, for example, if the phone that's found, I want to create it. 55 00:03:09,580 --> 00:03:12,540 OK, and I want to put specific value inside it. 56 00:03:12,870 --> 00:03:17,520 Then I will read it so you can see that there is some practical things here, actually. 57 00:03:18,120 --> 00:03:24,930 And if the pilot error or whatever, and this happens for a lot of use cases, for a lot of situations, 58 00:03:24,930 --> 00:03:27,120 whatever they are, you can just read about it. 59 00:03:27,120 --> 00:03:28,050 So it's no big deal. 60 00:03:28,530 --> 00:03:32,250 OK, then I will do specific things or whatever. 61 00:03:32,550 --> 00:03:33,900 OK, yeah, you can see that. 62 00:03:33,900 --> 00:03:41,250 By the way, I am writing the printer in a bad way, so it's trying and not print and you can see that 63 00:03:41,250 --> 00:03:47,940 it didn't show me any all by the way, why this happened actually because that interpreter, the interpreter 64 00:03:48,150 --> 00:03:51,060 is doing the things step by step. 65 00:03:51,270 --> 00:03:56,500 So it will go to the right, then to the alphabet, then to the print and then to the left and so on. 66 00:03:56,700 --> 00:04:03,840 So you can see that the sequentially and then check the syntax so you can see that the print is written. 67 00:04:04,230 --> 00:04:06,840 There was error in the syntax, the print. 68 00:04:06,960 --> 00:04:08,310 I wrote it in the wrong way. 69 00:04:09,090 --> 00:04:14,640 So it didn't show anything here because except go to the pilot and it's stuck there. 70 00:04:15,360 --> 00:04:18,260 So it didn't go to the except on the right. 71 00:04:18,510 --> 00:04:20,150 OK, thanks for watching. 72 00:04:20,310 --> 00:04:21,530 I will see you in the next picture.