We start Day 15 by revisiting special methods and how they combine to create objects with specific characteristics.
Today’s content is a bit longer than usual. However, you’ll come across topics you already covered earlier in the course.
We start Day 15 by revisiting special methods and how they combine to create objects with specific characteristics.
Today’s content is a bit longer than usual. However, you’ll come across topics you already covered earlier in the course.
00:00 Earlier in this course, you’ve seen how dunder methods or special methods, as they’re officially called, are linked to certain Python properties, and you’ve also seen how they’re linked directly to some data types.
00:13
For example, an Iterable is an Iterable because the Dunder __iter__
special method is there, and the iterator needs two special methods, the Dunder, __iter__
, and the Dunder __next__
.
00:24 However, some categories of data types are a bit more complex and they need more than just one or two dunder methods.
00:33 Today we’re going to look at two of the most common categories of data types, sequences such as lists and tuples, and mappings, such as dictionaries. What makes a data type a sequence and the answer is a certain collection of dunder methods, not just one or two, but a collection of them that are all needed.
00:54 And if they’re all present in a certain class, then that class is a sequence or creates objects that are a sequence. And likewise for mappings, there’s a different set of dunder methods and if they’re all present, that is what defines an object as being a mapping.
01:12 Today’s content is a bit long, but you will be revisiting some items, some, some, some topics that you’ve already discussed and you’ve already seen before.
01:24 So feel free to gauge your speed if, if it’s something that you’ve already come across, you can obviously go through it quicker.
You must own this product to join the conversation.