English subtitles

← Defining Class Movie - Programming Foundations with Python

Get Embed Code
7 Languages

Showing Revision 9 created 05/24/2016 by Udacity Robot.

  1. Okay, so the design of our class Movie, is
  2. here on the top right, [SOUND] and I'm going
  3. to begin, with a blank programming file. I have
  4. named it, media.py, and it is saved inside a
  5. folder called, movies. Now, to write a new class,
  6. [SOUND] I will used the Python keyword, class. And
  7. I will name it, Movie. You've probably notices, that
  8. the first letter of the name of the class M,
  9. is in uppercase. Now, this letter doesn't necessarily
  10. need to be in uppercase, but, the Google style
  11. guide for Python suggests that it should be.
  12. Now, what is this thing called the Google style
  13. guide for Python you ask, Well, let's Google
  14. it. The first link here looks good to me.
  15. Now, this Style Guide, provides conventions to programmers all
  16. over the world. On how to write their programs.
  17. If you scroll down a bit You will notice
  18. that there are conventions on everything, from how to name
  19. things, to how to write comments. By the way,
  20. the link to this webpage, is available in the instructor
  21. notes. I recommend that you read through this document.
  22. If you click on this link called Naming, you will
  23. notice that, when defining a class name, Google recommends that
  24. the first letter of that name be in capital letters.
  25. Okay, back to the code. Now, thus far, we've
  26. encountered one new key word, called class. In fact, we
  27. are going to come across several new words in this
  28. lesson, and I want to list them all, in one
  29. place for handy reference. The word class, is the first
  30. one on that list. We will review, all the words
  31. on this list before we end this lesson. So, you
  32. may have noticed that our class, is empty thus far.
  33. Now, to figure out what I want to do next
  34. with it, I will go back to my design. So,
  35. here I am, back with my class design. Now, I
  36. know that eventually, I would want to create multiple instances
  37. of the class movie. Instances like, Toy Story and
  38. Avatar. I also know that I have previously created instances
  39. of class Turtle. Instances like Brad, and to do that,
  40. I had to write a piece of code that read,
  41. turtle.Turtle, so I guess I will have to write a piece of code like
  42. this, to create Toy Story, an instance of class Movie. Let's do that next.