Class methods are functions contained in a class. There are rules for how methods interact with objects and data. Some capabilities require specially named methods.
- [Instructor] A function that is associated with a class…is called a method.…This provides the interface to the class and its objects.…Here in Komodo, I've opened a working copy of methods.py…from chapter nine of the exercise files.…And if we look down here, we'll find this method called type…which serves as both a getter and a setter,…and so I call it a getter setter.…You'll notice that the first argument to the function…is self, and that's what makes this a method…and not just a plain function.…
This is filled in automatically,…when I call this method on the object,…I don't provide this argument.…So I'll just provide one argument,…and the fact that it's being called on the method…will provide the first argument, self.…It's common to name this argument self,…although it's not required,…you can name it whatever you'd like.…But it's a really good idea to always use the word self,…because it's traditional,…and when people are reading your code,…they'll know what it means.…So in this case, the second argument is t,…
- Python anatomy
- Types and values
- Conditionals and operators
- Building loops
- Defining functions
- Python data structures: lists, tuples, sets, and more
- Creating classes
- Handling exceptions
- Working with strings
- File input/output (I/O)
- Creating modules
- Integrating a database with Python db-api
Skill Level Intermediate
Python: Programming Efficientlywith Michele Vallisneri2h 15m Intermediate
2. Language Overview
3. Types and Values
8. Structured Data
11. String Objects
12. File I/O
13. Built-in Functions
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.