Python Programming: Lesson 67 - The Callable Function

Опубликовано: 21 Ноябрь 2021
на канале: youmils03
86
1

PLEASE SUBSCRIBE!!!

In the previous video (   • Python Programming: Lesson 66 - Froze...  ), we brought up the notion of a frozen dictionary. It's a collection of key-value pairs that's immutable:
1. unlike a regular dictionary, we cannot add key-value pairs
2. unlike a regular dictionary, we cannot remove key-value pairs
3. unlike a regular dictionary, we cannot change the values associated with keys

However, we can do everything else, and we define each behavior using an appropriate instance method (some of them are magic methods)
1. len
2. add
3. contains
...

In this video, we further explore frozen dictionaries. We review inheritance (   • Python Programming: Lesson 34 - Inher...  ) by creating a subclass of our frozenDict class. The only difference between the superclass and subclass is that the subclass is callable because it supplies a call magic method. This allows us to treat callable frozen dictionaries like functions, but not traditional frozen dictionaries. In Python, callable(x) accepts an input x and returns True if and only if either of the following hold:
1. x is a function
2. x is an instance of a class that has a call magic method

0:41 Review of exec(x), iter(x), and eval(x)
3:40 Review of JSON
6:46 Review of Frozen Dictionaries
13:14 NEW: The Callable Function

Have you ever heard of a hexadecimal number? Check out hex numbers in Python, more content ahead!    • Python Programming: Lesson 68 - Hexad...  

Thanks for watching, and PLEASE SUBSCRIBE!!!


Смотрите видео Python Programming: Lesson 67 - The Callable Function онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь youmils03 21 Ноябрь 2021, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 86 раз и оно понравилось 1 людям.