Viewers: in countries Watching now:
Due to its power, simplicity, and complete object model, Python has become the scripting language of choice for many large organizations, including Google, Yahoo, and IBM. In Python 3 Essential Training, Bill Weinman demonstrates how to use Python 3 to create well-designed scripts and maintain existing projects. This course covers the basics of the language syntax and usage, as well as advanced features such as objects, generators, and exceptions. Example projects include a normalized database interface and a complete working CRUD application. Exercise files accompany the course.
Sometimes when running error into your code, they won't be syntax errors. instead they will be errors that don't show up until you try to run the code. We call these runtime errors. And we got some examples here. Let's make a working copy of this mvc errors.py, and we'll call this mvc-working.py. Open up that working copy and here we have demonstration file of a mvc model.
mvc stands for Model View Controller, and if we run this and look at the output, you'll see that things aren't quite okay in the first forest here. So couple of places we have this bound method being printed out and that is not necessarily what we are looking for. So let's see we can hunt this bound. It says bound method Duck.feathers, bound method Person.feathers, bound method Dog.feathers.
And so here is the feathers method. This gets inherited. We have Duck, Person and Dog and these are all inherit animal actions and the animal actions has the method feathers. So like it's inherited into these different classes, and that's getting printed out some place. So when we see this string in Python that says bound method blah, blah, blah, that means that you are trying to print a method, rather than calling it in.
It usually means missed parenthesis. That's the most common thing here. And so Ecllipse is actually helping me here. Because I put my cursor on feathers up here, it's highlighting all the places where it sees the word feathers, and so this is jumping out at me here, and you'll notice that it's missing the parenthesis. So if I go ahead and put those parenthesis in, see I was printing the method instead of calling the method and printing what it returns. So if I save that and run it, now we don't get that error any more.
And we have quack, the duck has no feathers, the person imitates a duck, and I am going to just say, "wait a minute, the duck has no feathers?" Ducks have feathers. And I know that I typed in feathers for the duck. See, the duck has gray and white feathers, and so why is it printing it this way? Well, you'll notice that the feathers method cause doAction for feathers and what doAction does is it looks for the strings with the action, and so the strings is defined in each of these animals.
So I have strings here, strings there. So this is where strings are defined and it's looking for feathers, which is spelled wrong. And if I correct that spelling and save that and run it and we will look at our result here, we now see that the duck has gray and white feathers So often times it's a typo like that and these kind of things can be hard to find. The trick is to go through the code, to follow the execution path of the code, and to say if this gets called by that, that gets called by this, this is the way that's supposed to work and just take your time and be patient and try not get flummoxed by the error.
I like to say the computers have infinite patience. It will sit there and stare at you with the error for as long as it takes. The trick is for you to try and gain as much as patience as the computer has in order to be able to find the errors. So often times these things just take patience, but the methodology is to go through the execution of the code and to look at all of the pieces that are supposed to fit together and try and find out piece that's not fitting together the way that it is supposed to.
Find answers to the most frequently asked questions about Python 3 Essential Training .
Here are the FAQs that matched your search "" :
Sorry, there are no matches for your search "" —to search again, type in another word or phrase and click search.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.