Pythonisms
Dunder Methods
Dunder methods are special methods that allow you to emulate the behavior of built-ins in classes
Kinds of dunder methods:
init : sets up the object with the necessary parts of the object
str : shows a representation of the object as a string to the user
len : can use len on the object specific to how that specific class is constructed
eq : checks if the same value in two objects are the same
add : allows you to add the same value of two different objects
call : allows you to print a readout of certain characteristics of the objects, whatever you would like it to show
The main thing to understand with dunder methods is that you can essentially set them to do anything that you would like them to do, the only limit is really your understanding of the object structure itself.
Iterators
- Repeater: A class that allows you to repeat a something forever
Things I want to know more about
-
The repeater class makes a fair amount of sense to me, but I don’t quite understand the applications of it in the real world besides understanding what is happening under the hood of a for loop better.
-
If I’m being completely honest I think I’m going to need to have the idea of generators explained to me in lecture to understand what their purpose is