-
Cím:
What Is Going On Behind the Scenes - Programming Foundations with Python
-
Leírás:
-
Okay, so here is the code for the class Movie
-
that we have written thus far. Now, bear in mind, that
-
you may have to go into full-screen mode in order
-
to see all of the details here properly. And I'm really
-
curious to figure out what happens behind the scenes when
-
I run this line of code. What happens when I create
-
an instance called toy_story by providing these four pieces of
-
information or arguments. These pieces of information are the name of
-
the movie, its story line, the link to its poster,
-
and the link to its YouTube URL. Now clearly, the
-
last two of these are not really links or URLs
-
just yet. They are English phrases and I did that because
-
there wasn't enough space on the screen for me to
-
add the full links or the URLs to the poster and
-
the YouTube trailer. So, the first thing that happens when
-
we learn this line of code is that the init function
-
gets called. And the init function, you
-
will recall, is the function we defined inside
-
class Movie. Self, in that case, is itself
-
or the instance being created, which is toy_story.
-
The next argument is movie_title whose value
-
is Toy Story. Movie_storyline gets the value Toys
-
come to life. The variable poster_image gets the
-
right value. And finally, the trailer_youtube variable gets
-
the correct link. Okay, so far so good. Now, once init gets called and
-
all of these arguments receive their correct
-
values, all of the variables that are associated
-
with the instance toy_story, they get initialized
-
appropriately and these variables, you may notice,
-
are title, storyline, poster_image_url and trailer_youtube_url. At
-
this point, if I try to print out
-
toy_story.storyline, it prints out the correct value. All right,
-
now that we know exactly what happens when we create
-
this instance toy story. Let's go back to our
-
design and find out what we have to do next.