PLEASE SUBSCRIBE!!!
In the previous lesson ( • Python Programming: Lesson 59 - More ... ), we saw another example or two of callable instances, which enable us to treat an instance of a class as though it were a function to be called. In this lesson, we learn a final magic method called __contains__. We also bring up a few basic topics, such as seeing if a string represents a keyword in Python or checking the type of an object/item. Use standard type(x) or the keyword(s) function from the iskeyword module.
The _call_ magic method of a class C allows us to create an instance E of C as though it were a function E( ) that we could call, potentially with inputs.
The _contains_ magic method of a class C allows us to define X in E for some item X and instance E of C. It is instructed to return True or False.
the iskeyword(s) function from the keyword module returns True if s is a Python keyword (shows up in orange), False otherwise
type(x) shows us the data type of the item x
5:02 Review of the call magic method
10:08 NEW: The contains magic method
12:39 NEW: The keyword function in the iskeyword module
16:46 NEW: type(x) Function
Ok, ready to keep going? More and more videos fresh for your eyes and ears: • Python Programming: Lesson 61 - Runni...
Thanks for watching, and PLEASE SUBSCRIBE!!!
Watch video Python Programming: Lesson 60 - The __contains__ Magic Method and Keywords in Python online, duration hours minute second in high quality that is uploaded to the channel youmils03 01 November 2021. Share the link to the video on social media so that your subscribers and friends will also watch this video. This video clip has been viewed 250 times and liked it 3 visitors.