1
00:00:03,330 --> 00:00:10,500
Hey, in today's bonus example, I want to work on yesterday's bonus example where we build this script.

2
00:00:10,530 --> 00:00:16,710
If you don't have this, you can find it attached in the lecture resources in this lecture for your

3
00:00:16,710 --> 00:00:17,700
convenience.

4
00:00:19,200 --> 00:00:22,640
The script we developed yesterday in bonus examples.

5
00:00:22,640 --> 00:00:30,450
So what it does is it allows the user to enter FT and inches such as 312 and then it replies.

6
00:00:32,740 --> 00:00:36,700
With this message, converting those feet and inches to meters.

7
00:00:36,700 --> 00:00:43,720
And then it also says if that kids can use this light or not, depending on how tall that kid is.

8
00:00:44,440 --> 00:00:46,870
So if it's below one meter.

9
00:00:49,050 --> 00:00:54,400
That's kids cannot use the slides, otherwise they can use it as it is the case here.

10
00:00:54,420 --> 00:00:55,770
1.2 metres.

11
00:00:56,940 --> 00:01:01,290
Now we want to improve this script today.

12
00:01:02,530 --> 00:01:05,560
By splitting it across different files.

13
00:01:08,690 --> 00:01:11,860
Of importing those files in the main file.

14
00:01:11,870 --> 00:01:14,210
So how would we do this?

15
00:01:15,110 --> 00:01:22,580
Well, you probably know that we normally take the functions and put them in separate files.

16
00:01:25,040 --> 00:01:27,230
So we have a post function.

17
00:01:29,260 --> 00:01:36,070
Which pauses the string that the user enters in the command line and it returns a dictionary.

18
00:01:36,780 --> 00:01:41,680
Then we have this convert function which gets FT and inches as numbers.

19
00:01:42,940 --> 00:01:45,250
And it converts them to meters.

20
00:01:46,240 --> 00:01:52,560
What I'll do now is I will consider that this program may become bigger in the future.

21
00:01:52,570 --> 00:01:56,480
So I would go and right click on bonus.

22
00:01:56,500 --> 00:02:01,240
This is a folder where bonus 14 is.

23
00:02:02,610 --> 00:02:12,330
So Bono's 14 is an empty file and in bonus 14 I'm going to place all the codes of bonus 13.

24
00:02:12,600 --> 00:02:14,580
So copied and pasted here.

25
00:02:14,850 --> 00:02:19,170
And then I'm going to put this function into a separate file.

26
00:02:20,250 --> 00:02:24,600
You can do that manually by creating a file inside.

27
00:02:24,600 --> 00:02:29,190
Bonus of bonus is the folder which contains bonus 14.

28
00:02:29,190 --> 00:02:38,460
So in the same folder you want to manually create a new file or you can use the par charm refactoring

29
00:02:38,460 --> 00:02:42,720
feature to create that file automatically.

30
00:02:44,880 --> 00:02:47,370
For that you need to select.

31
00:02:48,540 --> 00:02:49,680
The function.

32
00:02:50,560 --> 00:02:59,890
The entire function and right click and go to refactor and then you want to go to move.

33
00:03:00,010 --> 00:03:03,430
So you want to move that function to another file.

34
00:03:03,430 --> 00:03:09,810
So you want to move it from bonus 14 the current file to another file.

35
00:03:09,820 --> 00:03:12,160
So let's say this is going to be.

36
00:03:13,230 --> 00:03:15,930
Passers, passers.

37
00:03:15,930 --> 00:03:19,050
You can just say passers or you can say passers.

38
00:03:19,050 --> 00:03:19,980
14.

39
00:03:21,210 --> 00:03:23,130
Wherever you prefer, I'll just keep it.

40
00:03:23,130 --> 00:03:26,760
Parsers $0.14 and press on refactor.

41
00:03:27,240 --> 00:03:28,890
This is what happened now.

42
00:03:30,690 --> 00:03:36,120
One is that the function purser disappeared from Bones 14.

43
00:03:36,600 --> 00:03:41,490
Second is that this line was added by Parcham charm.

44
00:03:41,850 --> 00:03:49,110
This is saying from bonus that Porsche's 14 import pause parse was the name of the function.

45
00:03:49,290 --> 00:03:58,040
Bonus is the name of this folder and parsers 14 is the file that was created by Power charm.

46
00:03:58,290 --> 00:04:01,140
So parsers 14 is this file.

47
00:04:01,500 --> 00:04:06,120
And the this file contains the definition of the parse function.

48
00:04:07,960 --> 00:04:12,190
So this is an automatic process that offers.

49
00:04:12,190 --> 00:04:14,650
But you can, of course, do that manually.

50
00:04:14,650 --> 00:04:22,600
As I was explaining you, right click, create the file, put the function in there, and then import

51
00:04:23,830 --> 00:04:25,010
parts from here.

52
00:04:25,030 --> 00:04:28,270
Now, the way to import powers is.

53
00:04:29,590 --> 00:04:30,910
There are two ways actually.

54
00:04:30,910 --> 00:04:37,110
So this is one way from bonus dot passers for teen import pause or both.

55
00:04:37,120 --> 00:04:41,440
You can also say just from posters for teen.

56
00:04:42,710 --> 00:04:43,880
Import pass.

57
00:04:43,880 --> 00:04:45,590
This would also work.

58
00:04:47,340 --> 00:04:54,750
This works because pastors 14 and bonus 14 are in the same directory.

59
00:04:54,750 --> 00:04:56,520
So this works.

60
00:04:56,790 --> 00:05:06,390
But this also works because bonus is located in the project directory in the patch or project directory.

61
00:05:06,390 --> 00:05:08,520
And that directory is also.

62
00:05:09,580 --> 00:05:15,580
Included in the namespace, so both versions are fine to use.

63
00:05:16,240 --> 00:05:20,050
Let's try the same with the convert function.

64
00:05:20,050 --> 00:05:22,840
I'm going to right click over convert.

65
00:05:23,590 --> 00:05:26,010
Go to refactor, go again to move.

66
00:05:26,020 --> 00:05:28,540
This time we want to give this another name.

67
00:05:28,600 --> 00:05:33,040
So converters maybe 14.

68
00:05:34,140 --> 00:05:41,010
Press refactor and again the convert function was moved out of here.

69
00:05:41,040 --> 00:05:52,230
This line was added and a converters 14 dot p file was generated with the definition of convert inside.

70
00:05:55,000 --> 00:05:57,160
So that is our front end.

71
00:05:58,720 --> 00:06:05,800
Now we get those functions, so we have them here and we ask the user to enter, feed on inches.

72
00:06:05,890 --> 00:06:11,590
We create this variable pause equal to pause filled inches.

73
00:06:13,550 --> 00:06:23,600
So you see that post is directly referred to as opposed to being serves 14.

74
00:06:23,930 --> 00:06:37,550
This would also work, but you'd have to do import poor service 14, which is yet another way of importing.

75
00:06:38,900 --> 00:06:41,390
So feel free to use any of them.

76
00:06:42,260 --> 00:06:44,180
I'll just keep it as it is.

77
00:06:45,740 --> 00:06:46,490
Supports.

78
00:06:46,490 --> 00:06:47,600
And then we got the results.

79
00:06:47,600 --> 00:06:49,970
We print out that string.

80
00:06:50,000 --> 00:06:53,900
We check if the result is less than one and we print that.

81
00:06:54,830 --> 00:06:55,760
String.

82
00:06:56,150 --> 00:06:58,640
Otherwise, we print that other string.

83
00:06:59,150 --> 00:07:04,670
So if I run this, it's going to work just fine.

84
00:07:06,230 --> 00:07:06,530
Right.

85
00:07:06,530 --> 00:07:11,150
So that was about this video I used to modules.

86
00:07:11,150 --> 00:07:21,500
This time you could also use one single module and put both the convert and the pause function in one

87
00:07:21,500 --> 00:07:22,570
single file.

88
00:07:22,610 --> 00:07:24,830
Why did I use two files?

89
00:07:24,860 --> 00:07:29,450
Well, because I think these functions are a bit different from each other.

90
00:07:30,620 --> 00:07:33,890
So one is for parsing, another is for converting.

91
00:07:33,950 --> 00:07:34,580
So.

92
00:07:35,890 --> 00:07:44,800
I foresee that in the future I'll have more passing functions and that will allow me to extend the program

93
00:07:44,800 --> 00:07:47,620
easier, the app easier.

94
00:07:47,770 --> 00:07:51,310
So later I can just add more pass functions here.

95
00:07:52,680 --> 00:07:55,050
Maybe I want to pause different.

96
00:07:56,080 --> 00:07:57,370
Metric units.

97
00:07:57,370 --> 00:08:07,360
So I can add those functions in here, although it is debatable whether it is a good idea to put both

98
00:08:07,360 --> 00:08:09,580
converts and parts in one single file.

99
00:08:09,580 --> 00:08:11,950
So both ways are fine.

100
00:08:13,530 --> 00:08:14,400
Don't overthink.

101
00:08:14,400 --> 00:08:15,180
Think about that.

102
00:08:17,790 --> 00:08:19,110
And that was about this video.

103
00:08:19,140 --> 00:08:19,650
Thanks a lot.

104
00:08:19,680 --> 00:08:20,280
See you later.

