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!!!
Смотрите видео Python Programming: Lesson 60 - The __contains__ Magic Method and Keywords in Python онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь youmils03 01 Ноябрь 2021, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 250 раз и оно понравилось 3 людям.