- [Instructor] In the previous example,…we saw how to use special Python class methods…to generate string representation of objects.…In this example, we'll take the customization…a step further.…Python provides a set of methods…that classes can use to control…how attributes are accessed on an object.…Whenever an object's attributes are retrieved or set,…Python calls one of these functions…to give your class an opportunity…to perform any desired processing.…The first two, getattribute and getattr,…are called to retrieve an attribute value.…
Now these are slightly different from each other,…but it's important to know the difference.…Getattr is called only when the requested attribute…can't be found on the object,…while getattribute is called unconditionally…every time an attribute name is requested.…It's also called by Python when it goes…to look up any methods on your class,…so you need to be really careful with it.…The setattr function is called when an attribute value…is set on the object.…Delattr is called to delete an attribute…
- Truth value testing
- Template strings
- Advanced Python functions
- Advanced collections
- Advanced classes and objects
- Python comprehensions: list, dictionary, and set
Skill Level Advanced
1. Python Language Features
2. Built-In Functions
3. Advanced Python Functions
4. Advanced Collections
5. Advanced Classes and Objects
6. Using Logging
7. Python Comprehensions
- 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.