Python Programming: Lesson 67 - The Callable Function

Published: 21 November 2021
on channel: 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!!!


Watch video Python Programming: Lesson 67 - The Callable Function online, duration hours minute second in high quality that is uploaded to the channel youmils03 21 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 86 times and liked it 1 visitors.