1
00:00:00,000 --> 00:00:03,990
Sometimes when running error into your code, they won't be syntax errors.

2
00:00:04,000 --> 00:00:07,990
instead they will be errors that don't show up until you try to run the code.

3
00:00:08,000 --> 00:00:09,990
We call these runtime errors.

4
00:00:10,000 --> 00:00:10,990
And we got some examples here.

5
00:00:11,000 --> 00:00:17,990
Let's make a working copy of this mvc errors.py, and we'll call

6
00:00:18,000 --> 00:00:23,990
this mvc-working.py.

7
00:00:24,000 --> 00:00:31,990
Open up that working copy and here we have demonstration file of a mvc model.

8
00:00:32,000 --> 00:00:41,990
mvc stands for Model View Controller, and if we run this and look at the output,

9
00:00:42,000 --> 00:00:46,990
you'll see that things aren't quite okay in the first forest here.

10
00:00:47,000 --> 00:00:53,990
So couple of places we have this bound method being printed out

11
00:00:54,000 --> 00:00:59,990
and that is not necessarily what we are looking for.

12
00:01:00,000 --> 00:01:01,990
So let's see we can hunt this bound.

13
00:01:02,000 --> 00:01:07,990
It says bound method Duck.feathers, bound method Person.feathers,

14
00:01:08,000 --> 00:01:09,990
bound method Dog.feathers.

15
00:01:10,000 --> 00:01:15,990
And so here is the feathers method. This gets inherited. We have Duck, Person

16
00:01:16,000 --> 00:01:22,990
and Dog and these are all inherit animal actions and the animal actions has

17
00:01:23,000 --> 00:01:24,990
the method feathers.

18
00:01:25,000 --> 00:01:28,990
So like it's inherited into these different classes, and that's getting

19
00:01:29,000 --> 00:01:29,990
printed out some place.

20
00:01:30,000 --> 00:01:34,990
So when we see this string in Python that says bound method blah, blah, blah,

21
00:01:35,000 --> 00:01:39,990
that means that you are trying to print a method, rather than calling it in.

22
00:01:40,000 --> 00:01:42,990
It usually means missed parenthesis.

23
00:01:43,000 --> 00:01:44,990
That's the most common thing here.

24
00:01:45,000 --> 00:01:49,990
And so Ecllipse is actually helping me here. Because I put my cursor on

25
00:01:50,000 --> 00:01:52,990
feathers up here, it's highlighting all the places where it sees the word

26
00:01:53,000 --> 00:01:57,990
feathers, and so this is jumping out at me here, and you'll notice that it's

27
00:01:58,000 --> 00:01:58,990
missing the parenthesis.

28
00:01:59,000 --> 00:02:03,990
So if I go ahead and put those parenthesis in, see I was printing the method

29
00:02:04,000 --> 00:02:05,990
instead of calling the method and printing what it returns.

30
00:02:06,000 --> 00:02:11,990
So if I save that and run it, now we don't get that error any more.

31
00:02:12,000 --> 00:02:17,990
And we have quack, the duck has no feathers, the person imitates a duck, and I am

32
00:02:18,000 --> 00:02:22,990
going to just say, "wait a minute, the duck has no feathers?" Ducks have feathers.

33
00:02:23,000 --> 00:02:26,990
And I know that I typed in feathers for the duck.

34
00:02:27,000 --> 00:02:32,990
See, the duck has gray and white feathers, and so why is it printing it this way?

35
00:02:33,000 --> 00:02:38,990
Well, you'll notice that the feathers method cause doAction for feathers and what

36
00:02:39,000 --> 00:02:44,990
doAction does is it looks for the strings with the action, and so the strings is

37
00:02:45,000 --> 00:02:48,990
defined in each of these animals.

38
00:02:49,000 --> 00:02:50,990
So I have strings here, strings there.

39
00:02:51,000 --> 00:02:57,990
So this is where strings are defined and it's looking for feathers, which is spelled wrong.

40
00:02:58,000 --> 00:03:05,990
And if I correct that spelling and save that and run it

41
00:03:06,000 --> 00:03:06,990
and we will look at our result here,

42
00:03:07,000 --> 00:03:10,990
we now see that the duck has gray and white feathers

43
00:03:11,000 --> 00:03:15,990
So often times it's a typo like that and these kind of things can be hard to find.

44
00:03:16,000 --> 00:03:21,990
The trick is to go through the code, to follow the execution path of the code,

45
00:03:22,000 --> 00:03:24,990
and to say if this gets called by that, that gets called by this, this is the

46
00:03:25,000 --> 00:03:29,990
way that's supposed to work and just take your time and be patient and try not

47
00:03:30,000 --> 00:03:31,990
get flummoxed by the error.

48
00:03:32,000 --> 00:03:34,990
I like to say the computers have infinite patience.

49
00:03:35,000 --> 00:03:38,990
It will sit there and stare at you with the error for as long as it takes.

50
00:03:39,000 --> 00:03:42,990
The trick is for you to try and gain as much as patience as the computer has in

51
00:03:43,000 --> 00:03:44,990
order to be able to find the errors.

52
00:03:45,000 --> 00:03:50,990
So often times these things just take patience, but the methodology is to go

53
00:03:51,000 --> 00:03:54,990
through the execution of the code and to look at all of the pieces that are

54
00:03:55,000 --> 00:03:57,990
supposed to fit together and try and find out piece that's not fitting together

55
00:03:58,000 --> 00:04:08,000
the way that it is supposed to.

