English feliratok

← What Is Going On Behind the Scenes - Programming Foundations with Python

Beágyazókód kérése
7 Languages

Showing Revision 8 created 05/25/2016 by Udacity Robot.

  1. Okay, so here is the code for the class Movie
  2. that we have written thus far. Now, bear in mind, that
  3. you may have to go into full-screen mode in order
  4. to see all of the details here properly. And I'm really
  5. curious to figure out what happens behind the scenes when
  6. I run this line of code. What happens when I create
  7. an instance called toy_story by providing these four pieces of
  8. information or arguments. These pieces of information are the name of
  9. the movie, its story line, the link to its poster,
  10. and the link to its YouTube URL. Now clearly, the
  11. last two of these are not really links or URLs
  12. just yet. They are English phrases and I did that because
  13. there wasn't enough space on the screen for me to
  14. add the full links or the URLs to the poster and
  15. the YouTube trailer. So, the first thing that happens when
  16. we learn this line of code is that the init function
  17. gets called. And the init function, you
  18. will recall, is the function we defined inside
  19. class Movie. Self, in that case, is itself
  20. or the instance being created, which is toy_story.
  21. The next argument is movie_title whose value
  22. is Toy Story. Movie_storyline gets the value Toys
  23. come to life. The variable poster_image gets the
  24. right value. And finally, the trailer_youtube variable gets
  25. the correct link. Okay, so far so good. Now, once init gets called and
  26. all of these arguments receive their correct
  27. values, all of the variables that are associated
  28. with the instance toy_story, they get initialized
  29. appropriately and these variables, you may notice,
  30. are title, storyline, poster_image_url and trailer_youtube_url. At
  31. this point, if I try to print out
  32. toy_story.storyline, it prints out the correct value. All right,
  33. now that we know exactly what happens when we create
  34. this instance toy story. Let's go back to our
  35. design and find out what we have to do next.