title
Raymond Hettinger - Super considered super! - PyCon 2015
description
"Speaker: Raymond Hettinger
Python's super() is well-designed and powerful, but it can be tricky to use if you don't know all the moves.
This talk offers clear, practical advice with real-world use cases on how to use super() effectively and not get tripped-up by common mistakes.
Slides can be found at: https://speakerdeck.com/pycon2015 and https://github.com/PyCon/2015-slides"
detail
{'title': 'Raymond Hettinger - Super considered super! - PyCon 2015', 'heatmap': [{'end': 536.156, 'start': 504.735, 'weight': 0.912}, {'end': 621.788, 'start': 557.894, 'weight': 0.853}, {'end': 934.672, 'start': 865.295, 'weight': 0.77}, {'end': 1153.412, 'start': 1093.914, 'weight': 0.853}, {'end': 1522.267, 'start': 1432.339, 'weight': 0.94}, {'end': 1865.964, 'start': 1824.328, 'weight': 0.722}, {'end': 1974.142, 'start': 1936.246, 'weight': 0.938}, {'end': 2533.111, 'start': 2501.751, 'weight': 0.738}], 'summary': "Explores the power of 'super' for dependency injection, inheritance in code reuse, subclassing to specialize robots, python mocking, and the linearization algorithm in python, emphasizing practical application and improved efficiency through live experiments and code editing.", 'chapters': [{'end': 181.078, 'segs': [{'end': 82.466, 'src': 'embed', 'start': 40.176, 'weight': 0, 'content': [{'end': 45.281, 'text': 'I will tell you about how to use Super for dependency injection, which is one of its magic superpowers.', 'start': 40.176, 'duration': 5.105}, {'end': 49.825, 'text': 'One of my goals here is to make sure that you know what Super really does.', 'start': 46.082, 'duration': 3.743}, {'end': 52.266, 'text': 'that you have a good mental model for it.', 'start': 50.706, 'duration': 1.56}, {'end': 57.107, 'text': "I could give you a series of rules for using it well, but I'm going to try an experiment.", 'start': 52.346, 'duration': 4.761}, {'end': 62.148, 'text': "I'm going to get three volunteers from the audience, one of whom tried to un-volunteer, but is now in.", 'start': 57.207, 'duration': 4.941}, {'end': 65.649, 'text': "And we'll conduct a little experiment up here.", 'start': 63.288, 'duration': 2.361}, {'end': 72.47, 'text': 'and the experiment is if we work out visually what Super does, will you be able to remember it??', 'start': 65.649, 'duration': 6.821}, {'end': 77.291, 'text': 'I believe the answer will be yes, with a live demo of people as classes.', 'start': 72.89, 'duration': 4.401}, {'end': 80.624, 'text': "So, we'll learn what super really does.", 'start': 79.003, 'duration': 1.621}, {'end': 82.466, 'text': "Then we'll do some magic with it.", 'start': 81.145, 'duration': 1.321}], 'summary': 'Learn how to use super for dependency injection and understand its magic powers through a live demo.', 'duration': 42.29, 'max_score': 40.176, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/EiOglTERPEo/pics/EiOglTERPEo40176.jpg'}], 'start': 8.206, 'title': "'unlocking the power of super'", 'summary': "Discusses the importance of 'super' for dependency injection, emphasizing the need for a good mental model and aims to demonstrate its usage through a live experiment and code editing.", 'chapters': [{'end': 181.078, 'start': 8.206, 'title': 'Unlocking the power of super', 'summary': "Discusses the usage and importance of 'super' for dependency injection, emphasizing the need for a good mental model and aims to demonstrate its usage through a live experiment and code editing.", 'duration': 172.872, 'highlights': ["The speaker focuses on the usage of 'super' for dependency injection and aims to provide a good mental model for its usage. The speaker emphasizes the importance of understanding 'super' for dependency injection and aims to provide a good mental model for its usage.", "The speaker plans to conduct a live experiment to visually demonstrate the functionality of 'super' and its ability to aid in remembering its usage. The speaker plans to conduct a live experiment to visually demonstrate the functionality of 'super' and its ability to aid in remembering its usage.", "The speaker intends to edit and modify live code to demonstrate the usage of 'super' for dependency injection. The speaker plans to edit and modify live code to demonstrate the usage of 'super' for dependency injection."]}], 'duration': 172.872, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/EiOglTERPEo/pics/EiOglTERPEo8206.jpg', 'highlights': ["The speaker focuses on the usage of 'super' for dependency injection and aims to provide a good mental model for its usage.", "The speaker plans to conduct a live experiment to visually demonstrate the functionality of 'super' and its ability to aid in remembering its usage.", "The speaker intends to edit and modify live code to demonstrate the usage of 'super' for dependency injection."]}, {'end': 758.015, 'segs': [{'end': 232.545, 'src': 'embed', 'start': 181.198, 'weight': 3, 'content': [{'end': 185.622, 'text': "What could possibly go wrong? But remember, you can always go over to Beasley's.", 'start': 181.198, 'duration': 4.424}, {'end': 186.843, 'text': 'OK All right.', 'start': 185.782, 'duration': 1.061}, {'end': 188.664, 'text': 'All right.', 'start': 188.364, 'duration': 0.3}, {'end': 189.865, 'text': 'So now you know what our goal is.', 'start': 188.684, 'duration': 1.181}, {'end': 195.205, 'text': 'Inheritance is really easy.', 'start': 193.382, 'duration': 1.823}, {'end': 197.969, 'text': 'Inheritance is a tool for code reuse.', 'start': 195.946, 'duration': 2.023}, {'end': 204.378, 'text': "The whole idea is there's code in some other class, and instead of copying it into your class, you want to reuse it.", 'start': 198.329, 'duration': 6.049}, {'end': 208.224, 'text': 'So when one of your clients an object calls you,', 'start': 204.879, 'duration': 3.345}, {'end': 216.591, 'text': 'You can either do the work yourself or you can hand it off to someone else who knows how to do the work.', 'start': 209.365, 'duration': 7.226}, {'end': 220.855, 'text': "So if somebody asks you what inheritance is for, don't give a Java answer.", 'start': 217.332, 'duration': 3.523}, {'end': 223.677, 'text': "It doesn't have to do with abstract base classes or whatnot.", 'start': 221.175, 'duration': 2.502}, {'end': 226.54, 'text': "What's inheritance for? It's a tool for code reuse.", 'start': 223.898, 'duration': 2.642}, {'end': 229.402, 'text': 'It lets one class use the code in another class.', 'start': 226.8, 'duration': 2.602}, {'end': 232.545, 'text': 'And how hard could that be? Not very hard.', 'start': 229.762, 'duration': 2.783}], 'summary': "Inheritance is a tool for code reuse, allowing one class to use code from another. it's an easy concept for code reusability.", 'duration': 51.347, 'max_score': 181.198, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/EiOglTERPEo/pics/EiOglTERPEo181198.jpg'}, {'end': 395.946, 'src': 'embed', 'start': 350.251, 'weight': 1, 'content': [{'end': 352.072, 'text': 'That also works perfectly.', 'start': 350.251, 'duration': 1.821}, {'end': 356.695, 'text': 'Mixing classes work that way and are fantastically useful.', 'start': 352.332, 'duration': 4.363}, {'end': 360.652, 'text': "Is multiple inheritance easy when there's no overlaps? Yep.", 'start': 357.055, 'duration': 3.597}, {'end': 364.154, 'text': 'And inheritance is a tool for what? Code reuse.', 'start': 361.052, 'duration': 3.102}, {'end': 366.095, 'text': 'Okay, I think you get the gist.', 'start': 364.294, 'duration': 1.801}, {'end': 369.877, 'text': 'So, multiple inheritance is easy, single inheritance is easy.', 'start': 366.795, 'duration': 3.082}, {'end': 370.537, 'text': "What's hard?", 'start': 369.977, 'duration': 0.56}, {'end': 378.381, 'text': "What if you have multiple inheritance and there's a diamond diagram and the same methods are repeated on either side of the chain?", 'start': 372.078, 'duration': 6.303}, {'end': 379.742, 'text': 'Then it gets harder.', 'start': 378.881, 'duration': 0.861}, {'end': 385.045, 'text': 'How much harder? It took a long, long time for computer science to work this out.', 'start': 380.102, 'duration': 4.943}, {'end': 388.707, 'text': 'And when they came up with it, they have a..', 'start': 385.905, 'duration': 2.802}, {'end': 393.821, 'text': 'proof that it is the optimum and best solution to this problem.', 'start': 390.433, 'duration': 3.388}, {'end': 395.946, 'text': "It's the C-cubed linearization algorithm.", 'start': 393.861, 'duration': 2.085}], 'summary': 'Multiple inheritance is easy, but gets harder with diamond diagram, solved by c-cubed linearization algorithm.', 'duration': 45.695, 'max_score': 350.251, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/EiOglTERPEo/pics/EiOglTERPEo350251.jpg'}, {'end': 501.194, 'src': 'embed', 'start': 470.836, 'weight': 2, 'content': [{'end': 474.197, 'text': 'How many of you realize that Python super is not like that at all?', 'start': 470.836, 'duration': 3.361}, {'end': 478.339, 'text': 'What is super in every other language is not Python super.', 'start': 474.538, 'duration': 3.801}, {'end': 482.661, 'text': 'What does it do in other languages? In other languages, it calls your parents.', 'start': 478.719, 'duration': 3.942}, {'end': 484.962, 'text': "In single inheritance, it's easy.", 'start': 482.961, 'duration': 2.001}, {'end': 491.605, 'text': "Hey, Dad, can I use the car? Multiple inheritance, it's also easy.", 'start': 485.422, 'duration': 6.183}, {'end': 493.365, 'text': 'Dad, can I use the car? No.', 'start': 492.145, 'duration': 1.22}, {'end': 496.633, 'text': 'Mom, can I have the car? Easy enough.', 'start': 493.705, 'duration': 2.928}, {'end': 501.194, 'text': 'Inheritance, whenever you call super, is about calling your parents.', 'start': 497.433, 'duration': 3.761}], 'summary': 'Python super behaves differently than super in other languages and is about calling parents in the context of inheritance.', 'duration': 30.358, 'max_score': 470.836, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/EiOglTERPEo/pics/EiOglTERPEo470836.jpg'}, {'end': 536.156, 'src': 'heatmap', 'start': 504.735, 'weight': 0.912, 'content': [{'end': 507.415, 'text': 'It does call parents, but not your parents.', 'start': 504.735, 'duration': 2.68}, {'end': 513.256, 'text': 'When you call super, whose parents get called? It is not your ancestors.', 'start': 508.015, 'duration': 5.241}, {'end': 515.537, 'text': "It's your children's ancestors.", 'start': 514.017, 'duration': 1.52}, {'end': 519.018, 'text': "So here's my family tree.", 'start': 516.116, 'duration': 2.902}, {'end': 524.559, 'text': "I've got Raymond, Ramon, and Gail, my parents.", 'start': 519.998, 'duration': 4.561}, {'end': 530.338, 'text': 'My wife, Dennis and Sharon, are over Rachel, her parents.', 'start': 525.325, 'duration': 5.013}, {'end': 533.394, 'text': 'But Rachel and I have a child, Matthew.', 'start': 531.072, 'duration': 2.322}, {'end': 536.156, 'text': 'So Matthew has a bigger family tree than we do.', 'start': 533.894, 'duration': 2.262}], 'summary': "Calling super refers to the children's ancestors, resulting in a bigger family tree for the child.", 'duration': 31.421, 'max_score': 504.735, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/EiOglTERPEo/pics/EiOglTERPEo504735.jpg'}, {'end': 621.788, 'src': 'heatmap', 'start': 557.894, 'weight': 0.853, 'content': [{'end': 564.274, 'text': 'What do you have to do to the blob? Linearize it, which means make a line out of.', 'start': 557.894, 'duration': 6.38}, {'end': 567.977, 'text': "And that's what the MRO does, the method resolution algorithm.", 'start': 564.755, 'duration': 3.222}, {'end': 570.259, 'text': 'So let me turn on that code.', 'start': 568.918, 'duration': 1.341}, {'end': 577.204, 'text': 'And one of the nice things about help is it shows the method resolution order.', 'start': 573.081, 'duration': 4.123}, {'end': 580.726, 'text': 'It says if you have an instance of Matthew, you start with Matthew.', 'start': 577.784, 'duration': 2.942}, {'end': 585.67, 'text': 'When Matthew calls super, it calls me.', 'start': 583.048, 'duration': 2.622}, {'end': 589.153, 'text': 'When I call super, it calls my dad.', 'start': 587.231, 'duration': 1.922}, {'end': 592.019, 'text': 'But then something interesting happens.', 'start': 590.438, 'duration': 1.581}, {'end': 597.001, 'text': "When you call super on Ramon, it doesn't go to his parent.", 'start': 592.319, 'duration': 4.682}, {'end': 600.023, 'text': "Remember, his parent is he's descended directly from Adam.", 'start': 597.021, 'duration': 3.002}, {'end': 609.307, 'text': 'It calls out to the side, which is kind of interesting because my father is about 10 years older than his wife.', 'start': 602.284, 'duration': 7.023}, {'end': 616.111, 'text': 'And so that means that when he was born, his super call went somewhere else other than where it goes now.', 'start': 610.548, 'duration': 5.563}, {'end': 621.788, 'text': 'So, his super-call, where it went, has changed over time.', 'start': 618.007, 'duration': 3.781}], 'summary': 'Mro linearizes blob, shows method resolution order, and demonstrates super calls.', 'duration': 63.894, 'max_score': 557.894, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/EiOglTERPEo/pics/EiOglTERPEo557894.jpg'}, {'end': 715.108, 'src': 'embed', 'start': 685.057, 'weight': 0, 'content': [{'end': 686.4, 'text': 'It means to make a line out of.', 'start': 685.057, 'duration': 1.343}, {'end': 689.988, 'text': 'It is what order to visit everybody at.', 'start': 687.342, 'duration': 2.646}, {'end': 694.955, 'text': 'What does Python super do? Does it call your parents? No.', 'start': 691.673, 'duration': 3.282}, {'end': 698.297, 'text': 'It calls the parents or ancestors of your children.', 'start': 695.415, 'duration': 2.882}, {'end': 702.54, 'text': "If you've learned that much, you know a great deal about Python super now.", 'start': 698.618, 'duration': 3.922}, {'end': 704.802, 'text': 'So what should it have been called??', 'start': 703.1, 'duration': 1.702}, {'end': 713.507, 'text': "Well, given that we've taken this diamond diagram and turned it into a line, the line down here, what super really should have been called,", 'start': 705.462, 'duration': 8.045}, {'end': 715.108, 'text': 'is the next in line.', 'start': 713.507, 'duration': 1.601}], 'summary': 'Python super is the next in line for calling parents or ancestors of children.', 'duration': 30.051, 'max_score': 685.057, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/EiOglTERPEo/pics/EiOglTERPEo685057.jpg'}], 'start': 181.198, 'title': 'Inheritance in code and python super', 'summary': "Delves into inheritance as a tool for code reuse, highlighting its practicality and enabling one class to utilize code from another. it also emphasizes understanding python's super function, the challenges of multiple inheritance, and the method resolution order.", 'chapters': [{'end': 232.545, 'start': 181.198, 'title': 'Understanding inheritance in code', 'summary': 'Discusses the concept of inheritance as a tool for code reuse, emphasizing its ease and practicality, and highlights its primary purpose as enabling one class to use the code in another class.', 'duration': 51.347, 'highlights': ['Inheritance is a tool for code reuse, allowing one class to utilize the code in another class.', 'Emphasizes the simplicity and ease of inheritance as a concept.', 'Highlights the primary purpose of inheritance as enabling code reuse.']}, {'end': 758.015, 'start': 233.325, 'title': 'Understanding python super and inheritance', 'summary': "Discusses the importance of understanding the supply chain, the concept of inheritance in python, the challenges of multiple inheritance, and the unique behavior of python's super function, emphasizing the use of linearization and the method resolution order.", 'duration': 524.69, 'highlights': ["Python super function behavior The Python super function behaves differently from that in other languages, as it calls the parents or ancestors of the children, not the caller's parents, leading to the unique method resolution order.", 'Challenges of multiple inheritance The chapter explains the complexities of multiple inheritance, particularly when dealing with diamond diagrams and the need for linearization to determine the method resolution order.', "The concept of linearization in Python inheritance The importance of linearization in Python inheritance is emphasized, as it determines the order of visiting everyone and how the super function behaves in calling the next in line rather than the caller's parents.", "Understanding the supply chain The discussion highlights the significance of understanding the supply chain, especially in terms of customer perception and the impact of suppliers on a company's reputation."]}], 'duration': 576.817, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/EiOglTERPEo/pics/EiOglTERPEo181198.jpg', 'highlights': ["The importance of linearization in Python inheritance is emphasized, as it determines the order of visiting everyone and how the super function behaves in calling the next in line rather than the caller's parents.", 'The chapter explains the complexities of multiple inheritance, particularly when dealing with diamond diagrams and the need for linearization to determine the method resolution order.', "Python super function behavior The Python super function behaves differently from that in other languages, as it calls the parents or ancestors of the children, not the caller's parents, leading to the unique method resolution order.", 'Inheritance is a tool for code reuse, allowing one class to utilize the code in another class.', 'Emphasizes the simplicity and ease of inheritance as a concept.', 'Highlights the primary purpose of inheritance as enabling code reuse.']}, {'end': 1219.737, 'segs': [{'end': 934.672, 'src': 'heatmap', 'start': 835.068, 'weight': 2, 'content': [{'end': 837.33, 'text': 'Remember, inheritance is a tool for code reuse.', 'start': 835.068, 'duration': 2.262}, {'end': 843.437, 'text': 'So lots of other Our classes can go to this dough factory and get their dough.', 'start': 837.73, 'duration': 5.707}, {'end': 847.22, 'text': "Have we improved the code? Yes, because we've eliminated redundancy.", 'start': 843.798, 'duration': 3.422}, {'end': 851.284, 'text': 'The problem is this dough factory is hardwired.', 'start': 848.281, 'duration': 3.003}, {'end': 859.47, 'text': 'And if we change the name of the dough factory, if we try to choose a different dough factory right here, we have to change it in two places.', 'start': 851.984, 'duration': 7.486}, {'end': 864.494, 'text': 'What does DRY stand for? Do not repeat yourself.', 'start': 860.511, 'duration': 3.983}, {'end': 873.707, 'text': "If I have to say it twice here, am I repeating myself? Ah, you all know, that's right.", 'start': 865.295, 'duration': 8.412}, {'end': 874.987, 'text': 'There must be a better way.', 'start': 873.887, 'duration': 1.1}, {'end': 876.568, 'text': 'And the better way is this.', 'start': 875.508, 'duration': 1.06}, {'end': 880.13, 'text': 'Oh, never do live coding.', 'start': 878.769, 'duration': 1.361}, {'end': 885.072, 'text': "I don't even see my cursor.", 'start': 883.932, 'duration': 1.14}, {'end': 894.477, 'text': "How is this possible, okay? Oh, it wants to know if it's changed on disk.", 'start': 888.714, 'duration': 5.763}, {'end': 896.518, 'text': "How is this possible? I don't know.", 'start': 894.797, 'duration': 1.721}, {'end': 905.73, 'text': 'Emacs! What does Emacs stand for? Exclusively used by middle-aged computer scientists.', 'start': 896.538, 'duration': 9.192}, {'end': 911.411, 'text': 'Okay All right.', 'start': 909.491, 'duration': 1.92}, {'end': 920.973, 'text': "Super In what way is the code better now? The way that the code is better now is simply that we didn't mention doe factory twice.", 'start': 912.332, 'duration': 8.641}, {'end': 927.374, 'text': 'So if I change to a different doe factory here, super will automatically be aware of it.', 'start': 921.373, 'duration': 6.001}, {'end': 930.915, 'text': 'That reduced redundancy in our code and makes it awesome.', 'start': 927.994, 'duration': 2.921}, {'end': 934.672, 'text': "Didn't I mention super is super? But I know what you're thinking.", 'start': 931.335, 'duration': 3.337}], 'summary': 'Inheritance reduces redundancy by enabling code reuse, improving code quality and making it easier to update, leading to more efficient and effective programming.', 'duration': 61.45, 'max_score': 835.068, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/EiOglTERPEo/pics/EiOglTERPEo835068.jpg'}, {'end': 958.908, 'src': 'embed', 'start': 931.335, 'weight': 1, 'content': [{'end': 934.672, 'text': "Didn't I mention super is super? But I know what you're thinking.", 'start': 931.335, 'duration': 3.337}, {'end': 937.754, 'text': "That's the same way you would use it in every other language that has super.", 'start': 934.892, 'duration': 2.862}, {'end': 939.115, 'text': 'And in fact, you would.', 'start': 938.154, 'duration': 0.961}, {'end': 942.817, 'text': 'Yet, you got a magic power, whether you knew it or not.', 'start': 939.755, 'duration': 3.062}, {'end': 946.279, 'text': "Let's look in detail at what's actually happening here.", 'start': 943.437, 'duration': 2.842}, {'end': 948.701, 'text': 'Yes, I want to save.', 'start': 947.64, 'duration': 1.061}, {'end': 952.444, 'text': 'I will go run our pizza factory.', 'start': 949.722, 'duration': 2.722}, {'end': 955.926, 'text': 'And what does it do? It goes to get dough.', 'start': 953.384, 'duration': 2.542}, {'end': 958.908, 'text': "That's the first step in making a pizza.", 'start': 957.087, 'duration': 1.821}], 'summary': "Exploring the use of 'super' in various programming languages and its application in a pizza factory process.", 'duration': 27.573, 'max_score': 931.335, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/EiOglTERPEo/pics/EiOglTERPEo931335.jpg'}, {'end': 1069.307, 'src': 'embed', 'start': 1042.228, 'weight': 4, 'content': [{'end': 1047.191, 'text': 'And this one gives you pure, untreated wheat dough with no insecticides.', 'start': 1042.228, 'duration': 4.963}, {'end': 1048.612, 'text': 'Good for you.', 'start': 1048.031, 'duration': 0.581}, {'end': 1050.573, 'text': "Here's your problem.", 'start': 1049.712, 'duration': 0.861}, {'end': 1056.136, 'text': 'Your problem is over here in this class, the dough factory is hardwired.', 'start': 1051.193, 'duration': 4.943}, {'end': 1059.618, 'text': "Or is it? It's not hardwired.", 'start': 1057.016, 'duration': 2.602}, {'end': 1065.926, 'text': 'one of the magic property of super in Python is the inheritance chain was not determined by pizza.', 'start': 1060.143, 'duration': 5.783}, {'end': 1069.307, 'text': 'The inheritance chain is determined by your children.', 'start': 1066.626, 'duration': 2.681}], 'summary': 'The wheat dough is pure and untreated, without insecticides. the inheritance chain in python is determined by children.', 'duration': 27.079, 'max_score': 1042.228, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/EiOglTERPEo/pics/EiOglTERPEo1042228.jpg'}, {'end': 1153.412, 'src': 'heatmap', 'start': 1093.914, 'weight': 0.853, 'content': [{'end': 1100.023, 'text': 'This is dependency injection with nothing up my sleeves without changing any of the code on the left side.', 'start': 1093.914, 'duration': 6.109}, {'end': 1102.747, 'text': 'I will magically improve our pizza.', 'start': 1100.724, 'duration': 2.023}, {'end': 1110.506, 'text': 'All we do is make an empty class, an organic pizza.', 'start': 1107.003, 'duration': 3.503}, {'end': 1114.21, 'text': 'Is that a subclass of pizza? Sure it is.', 'start': 1111.287, 'duration': 2.923}, {'end': 1116.912, 'text': 'Is it also a subclass of organic dough factory??', 'start': 1114.63, 'duration': 2.282}, {'end': 1126.541, 'text': 'Yes, and the linearization algorithm guarantees that the organic dough factory will go before the pizza factory, which is kind of awesome.', 'start': 1117.953, 'duration': 8.588}, {'end': 1129.123, 'text': "So now I'll go order it with anchovies.", 'start': 1127.082, 'duration': 2.041}, {'end': 1136.583, 'text': 'And without having changed the order pizza, notice that we now get pure, untreated wheat dough.', 'start': 1131.038, 'duration': 5.545}, {'end': 1141.628, 'text': "Who thinks that's awesome? You can take anybody.", 'start': 1137.044, 'duration': 4.584}, {'end': 1147.107, 'text': 'who has a supplier and they advertise their supplier as part of their API.', 'start': 1142.523, 'duration': 4.584}, {'end': 1150.65, 'text': "It's not actually hardwired the inheritance chain.", 'start': 1147.888, 'duration': 2.762}, {'end': 1153.412, 'text': 'It is telling you what the default supplier is.', 'start': 1151.13, 'duration': 2.282}], 'summary': 'Dependency injection improves pizza with organic dough, guaranteeing order of factories.', 'duration': 59.498, 'max_score': 1093.914, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/EiOglTERPEo/pics/EiOglTERPEo1093914.jpg'}, {'end': 1219.737, 'src': 'embed', 'start': 1196.791, 'weight': 0, 'content': [{'end': 1204.393, 'text': 'Part of the default supplier chain is documented to be dough factory and you are allowed to change the order.', 'start': 1196.791, 'duration': 7.602}, {'end': 1205.934, 'text': 'It does this by design.', 'start': 1204.693, 'duration': 1.241}, {'end': 1208.574, 'text': "It's not an accident of super that it does this.", 'start': 1206.134, 'duration': 2.44}, {'end': 1209.755, 'text': "It's an on purpose.", 'start': 1208.775, 'duration': 0.98}, {'end': 1215.196, 'text': 'The whole C-Cube algorithm was designed so you could do stuff exactly like this.', 'start': 1210.475, 'duration': 4.721}, {'end': 1219.737, 'text': "Is it a accident or an on purpose? It's an on purpose.", 'start': 1215.916, 'duration': 3.821}], 'summary': 'The c-cube algorithm allows changing orders in the dough factory supplier chain intentionally.', 'duration': 22.946, 'max_score': 1196.791, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/EiOglTERPEo/pics/EiOglTERPEo1196791.jpg'}], 'start': 758.835, 'title': 'Inheritance and code reuse', 'summary': "Discusses the concept of inheritance for code reuse using a dough factory example, emphasizing the importance of eliminating redundancy to improve efficiency, and explores the magic power of 'super' in python for controlling method resolution and enabling dependency injection, resulting in improved pizza production with organic dough.", 'chapters': [{'end': 930.915, 'start': 758.835, 'title': 'Inheritance and code reuse', 'summary': 'Discusses the concept of inheritance for code reuse, highlighting the implementation of a dough factory and the importance of eliminating redundancy in the code to improve efficiency.', 'duration': 172.08, 'highlights': ['The concept of inheritance as a tool for code reuse is explained, demonstrating how multiple classes can access the dough factory to obtain dough, thereby eliminating redundancy in the code.', 'The speaker emphasizes the significance of not repeating oneself (DRY) in coding, stressing the importance of reducing redundancy in the code to enhance its efficiency.', 'The example of a pizza class and its interaction with the dough factory is used to illustrate the process of code reuse through inheritance, showcasing the benefits of eliminating redundancy in the code.']}, {'end': 1219.737, 'start': 931.335, 'title': 'The magic power of super', 'summary': "Discusses the magic power of 'super' in python, demonstrating how it modifies inheritance chains to control the order of method resolution and enable dependency injection, resulting in improved pizza production with organic dough and highlighting the deterministic and intentional nature of the process.", 'duration': 288.402, 'highlights': ["The 'super' keyword in Python modifies inheritance chains to control the order of method resolution, enabling dependency injection. The 'super' keyword in Python allows for modifying the inheritance chain by creating a subclass that injects a new supplier in the chain, thereby controlling the order of method resolution and implementing dependency injection.", "The use of 'super' results in improved pizza production with organic dough, showcasing the deterministic and intentional nature of the process. By leveraging the 'super' keyword, the process results in improved pizza production with pure, untreated wheat dough from the organic dough factory, highlighting the intentional and deterministic nature of the inheritance chain modification.", "The chapter emphasizes the intentional design of the 'super' keyword and the C3 linearization algorithm to facilitate specific modifications in the inheritance chain. The intentional design of the 'super' keyword and the C3 linearization algorithm allows for specific modifications in the inheritance chain, demonstrating the deliberate and intentional nature of the process."]}], 'duration': 460.902, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/EiOglTERPEo/pics/EiOglTERPEo758835.jpg', 'highlights': ["The intentional design of the 'super' keyword and the C3 linearization algorithm allows for specific modifications in the inheritance chain, demonstrating the deliberate and intentional nature of the process.", "The use of 'super' results in improved pizza production with organic dough, showcasing the deterministic and intentional nature of the process.", 'The concept of inheritance as a tool for code reuse is explained, demonstrating how multiple classes can access the dough factory to obtain dough, thereby eliminating redundancy in the code.', 'The example of a pizza class and its interaction with the dough factory is used to illustrate the process of code reuse through inheritance, showcasing the benefits of eliminating redundancy in the code.', "The 'super' keyword in Python modifies inheritance chains to control the order of method resolution, enabling dependency injection.", 'The speaker emphasizes the significance of not repeating oneself (DRY) in coding, stressing the importance of reducing redundancy in the code to enhance its efficiency.']}, {'end': 1593.825, 'segs': [{'end': 1323.936, 'src': 'embed', 'start': 1296.898, 'weight': 0, 'content': [{'end': 1301.02, 'text': "So, how do you specialize your robot? It's a fairly easy thing.", 'start': 1296.898, 'duration': 4.122}, {'end': 1303.879, 'text': 'You subclass it.', 'start': 1303.018, 'duration': 0.861}, {'end': 1306.181, 'text': 'Subclassing is used to specialize.', 'start': 1304.039, 'duration': 2.142}, {'end': 1308.303, 'text': 'And so our extend.', 'start': 1306.861, 'duration': 1.442}, {'end': 1312.366, 'text': "We're going to extend the robot by adding a new method, clean.", 'start': 1308.503, 'duration': 3.863}, {'end': 1319.773, 'text': "And what clean does is take advantage of the parent methods and we're programming the robot to use something useful.", 'start': 1313.027, 'duration': 6.746}, {'end': 1321.714, 'text': 'This is not a toy example.', 'start': 1320.373, 'duration': 1.341}, {'end': 1323.936, 'text': 'This is a proper way to use subclassing.', 'start': 1321.754, 'duration': 2.182}], 'summary': 'Subclassing is a proper way to specialize a robot and add useful methods.', 'duration': 27.038, 'max_score': 1296.898, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/EiOglTERPEo/pics/EiOglTERPEo1296898.jpg'}, {'end': 1523.728, 'src': 'heatmap', 'start': 1432.339, 'weight': 1, 'content': [{'end': 1436.021, 'text': "But what the mock bot does is it doesn't actually do a physical movement.", 'start': 1432.339, 'duration': 3.682}, {'end': 1438.723, 'text': 'All it does is record all of the calls that are made to it.', 'start': 1436.241, 'duration': 2.482}, {'end': 1440.804, 'text': 'It appends it to a list of tasks.', 'start': 1438.943, 'duration': 1.861}, {'end': 1444.646, 'text': "You can call the mock bot as much as you want, and it won't wear out.", 'start': 1441.404, 'duration': 3.242}, {'end': 1453.311, 'text': 'All we need to do is go edit this code and force it is to temporarily edit the code, make it use the mock bot, and then switch it back.', 'start': 1445.547, 'duration': 7.764}, {'end': 1456.173, 'text': 'Good idea or bad idea? Bad idea.', 'start': 1453.531, 'duration': 2.642}, {'end': 1462.318, 'text': 'There is, and it only takes one line of code.', 'start': 1459.397, 'duration': 2.921}, {'end': 1465.34, 'text': 'A mocked cleaning robot.', 'start': 1463.559, 'duration': 1.781}, {'end': 1469.102, 'text': 'It inherits from robot, and it inherits from mock bot.', 'start': 1465.78, 'duration': 3.322}, {'end': 1483.709, 'text': 'We are guaranteed by the linearization rules that any time our cleaning robot calls its supplier of robotic services that it will check for mock bot before it checks the actual robot.', 'start': 1469.622, 'duration': 14.087}, {'end': 1488.151, 'text': 'And so I can write a proper normal unit test to test clean.', 'start': 1484.369, 'duration': 3.782}, {'end': 1496.598, 'text': 'If I had this test, the cleaning robot, a real robot would be doing the physical movements as it did on the left.', 'start': 1489.311, 'duration': 7.287}, {'end': 1497.859, 'text': 'Of course, wearing it out.', 'start': 1496.798, 'duration': 1.061}, {'end': 1502.043, 'text': 'But with my mop cleaning robot, I can go tell it to clean with a mop.', 'start': 1498.419, 'duration': 3.624}, {'end': 1505.646, 'text': 'And then I can expect that it gets this output.', 'start': 1503.584, 'duration': 2.062}, {'end': 1506.767, 'text': "Let's check it out.", 'start': 1506.066, 'duration': 0.701}, {'end': 1509.389, 'text': 'I got a dot.', 'start': 1508.768, 'duration': 0.621}, {'end': 1510.87, 'text': 'Very satisfying.', 'start': 1509.99, 'duration': 0.88}, {'end': 1514.493, 'text': 'What did you achieve at work today? The dot.', 'start': 1512.772, 'duration': 1.721}, {'end': 1522.267, 'text': "Your friends don't typically understand how satisfying it is to get a dot.", 'start': 1518.666, 'duration': 3.601}, {'end': 1523.728, 'text': 'Thank you, I saw that one.', 'start': 1522.628, 'duration': 1.1}], 'summary': 'The mock bot records calls, allowing unlimited use without wearing out. a mocked cleaning robot inherits from mock bot, enabling proper unit testing.', 'duration': 54.106, 'max_score': 1432.339, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/EiOglTERPEo/pics/EiOglTERPEo1432339.jpg'}], 'start': 1220.578, 'title': 'Subclassing, specializing robots, and testing mock robot', 'summary': 'Covers the process of subclassing to specialize a robot, including benefits and practical application, as well as creating a mock robot to test the clean method, achieving satisfying results by testing with a mop.', 'chapters': [{'end': 1372.981, 'start': 1220.578, 'title': 'Subclassing and specializing robots', 'summary': "Explains the process of subclassing to specialize a robot, including its benefits and how it's used to create a sweeping robot, demonstrating the practical application of subclassing.", 'duration': 152.403, 'highlights': ['Subclassing is used to specialize a robot by extending it with new methods, such as adding a clean method, which demonstrates a proper way to use subclassing.', 'The process of subclassing makes the robot programmable and enables it to perform specific tasks, as demonstrated by the creation of a sweeping robot using the subclassing approach.', 'The example emphasizes the practical application of subclassing by showcasing the design of a sweeping robot, Roomba, as a result of subclassing a general-purpose robot.']}, {'end': 1593.825, 'start': 1373.641, 'title': 'Testing mock robot for clean method', 'summary': 'Discusses creating a mock robot to test the clean method, ensuring the real robot is not worn out, using inheritance to switch between mock and real robot, and achieving a satisfying result by testing the clean method with a mop.', 'duration': 220.184, 'highlights': ['Creating a mock robot to test the clean method, preventing wear on the real robot, and recording all calls made to it. The mock robot records all calls made to it, preventing wear and tear on the real robot, allowing for proper normal unit tests to be written for the clean method.', 'Using inheritance to switch between the mock and real robot, ensuring that the mock bot is checked before the actual robot and allowing for testing the clean method with a mop. The mocked cleaning robot inherits from both robot and mock bot, guaranteeing that it checks for the mock bot before the actual robot, allowing for testing the clean method with a mop.', 'Achieving a satisfying result by testing the clean method with a mop and obtaining a dot as the output. By testing the clean method with a mop, a satisfying output of a dot is achieved, providing a sense of accomplishment and preventing wear on the real robot.']}], 'duration': 373.247, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/EiOglTERPEo/pics/EiOglTERPEo1220578.jpg', 'highlights': ['The process of subclassing makes the robot programmable and enables it to perform specific tasks, as demonstrated by the creation of a sweeping robot using the subclassing approach.', 'Creating a mock robot to test the clean method, preventing wear on the real robot, and recording all calls made to it.', 'Achieving a satisfying result by testing the clean method with a mop and obtaining a dot as the output.']}, {'end': 1799.351, 'segs': [{'end': 1622.905, 'src': 'embed', 'start': 1594.125, 'weight': 0, 'content': [{'end': 1597.827, 'text': 'And the next in the line is the mock bot ahead of the real robot.', 'start': 1594.125, 'duration': 3.702}, {'end': 1599.928, 'text': 'So the mock robot gets called first.', 'start': 1598.027, 'duration': 1.901}, {'end': 1602.009, 'text': 'This is dependency injection.', 'start': 1600.629, 'duration': 1.38}, {'end': 1604.151, 'text': "It's easy to do.", 'start': 1603.29, 'duration': 0.861}, {'end': 1606.132, 'text': "It's one line of code.", 'start': 1604.991, 'duration': 1.141}, {'end': 1607.713, 'text': 'Make a mock class.', 'start': 1606.712, 'duration': 1.001}, {'end': 1609.977, 'text': 'Inject it just with this.', 'start': 1608.556, 'duration': 1.421}, {'end': 1611.758, 'text': "There's nothing fragile about it.", 'start': 1610.357, 'duration': 1.401}, {'end': 1613.259, 'text': "It's guaranteed behavior.", 'start': 1612.178, 'duration': 1.081}, {'end': 1615.08, 'text': "It's what it was designed for.", 'start': 1613.599, 'duration': 1.481}, {'end': 1620.023, 'text': 'How many of you learned something new? My work is done.', 'start': 1615.601, 'duration': 4.422}, {'end': 1622.905, 'text': 'I could get off the stage right now and just declare victory.', 'start': 1620.043, 'duration': 2.862}], 'summary': 'Dependency injection allows easy and guaranteed behavior with just one line of code, making it robust and designed for the purpose.', 'duration': 28.78, 'max_score': 1594.125, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/EiOglTERPEo/pics/EiOglTERPEo1594125.jpg'}, {'end': 1674.051, 'src': 'embed', 'start': 1644.806, 'weight': 1, 'content': [{'end': 1648.028, 'text': 'What are counters good for? Counting things.', 'start': 1644.806, 'duration': 3.222}, {'end': 1650.05, 'text': 'They are a subclass of dict.', 'start': 1648.649, 'duration': 1.401}, {'end': 1654.913, 'text': 'Is a dict an ordered collection or an unordered collection? Unordered collection.', 'start': 1650.27, 'duration': 4.643}, {'end': 1658.275, 'text': "So we're going to get counts, but they're going to be scrambled.", 'start': 1655.333, 'duration': 2.942}, {'end': 1664.303, 'text': 'What else do we have in the collections module that remembers order? Order dictionaries.', 'start': 1659.176, 'duration': 5.127}, {'end': 1665.484, 'text': "That's fantastic.", 'start': 1664.543, 'duration': 0.941}, {'end': 1666.665, 'text': 'They remember the order.', 'start': 1665.504, 'duration': 1.161}, {'end': 1667.726, 'text': "That's a wonderful thing.", 'start': 1666.725, 'duration': 1.001}, {'end': 1671.309, 'text': "Do order dicks count? They don't.", 'start': 1668.527, 'duration': 2.782}, {'end': 1674.051, 'text': "So, you've got a devil's choice.", 'start': 1672.35, 'duration': 1.701}], 'summary': 'Counters in collections module are unordered subclass of dict, unlike ordered dictionaries.', 'duration': 29.245, 'max_score': 1644.806, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/EiOglTERPEo/pics/EiOglTERPEo1644806.jpg'}, {'end': 1743.216, 'src': 'embed', 'start': 1699.788, 'weight': 2, 'content': [{'end': 1705.27, 'text': 'I am guaranteeing a particular order of calls where the underlying dictionary comes last.', 'start': 1699.788, 'duration': 5.482}, {'end': 1714.212, 'text': 'So when a counter uses its default supplier of mapping services, its default supplier for mapping services is dict, which is unordered.', 'start': 1705.83, 'duration': 8.382}, {'end': 1719.754, 'text': "We're telling it to use another supplier, order dict, and it's a remarkably easy thing to compose.", 'start': 1714.792, 'duration': 4.962}, {'end': 1730.452, 'text': 'I went ahead and modified a couple things in the class because you want to give it a nice-looking wrapper so that it looks pretty and make it pickleable.', 'start': 1721.249, 'duration': 9.203}, {'end': 1736.554, 'text': "You do go ahead and polish up all your classes to make sure that they look nice and pickle, right? That's what I thought.", 'start': 1730.732, 'duration': 5.822}, {'end': 1743.216, 'text': "We'll go and run this, and presto, this counter has inside it an order dict.", 'start': 1737.334, 'duration': 5.882}], 'summary': 'Guarantee order of calls with order dict for mapping services, making counter pickleable.', 'duration': 43.428, 'max_score': 1699.788, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/EiOglTERPEo/pics/EiOglTERPEo1699788.jpg'}], 'start': 1594.125, 'title': 'Python mocking, counting, and ordered counter in python', 'summary': 'Covers dependency injection with mock classes, usage and features of counters in the collections module, and creating an ordered counter. it showcases simplicity and guaranteed behavior, one-line code implementation, and specific examples.', 'chapters': [{'end': 1699.288, 'start': 1594.125, 'title': 'Python mocking and counting in collections', 'summary': 'Discusses dependency injection with mock classes in python, showcasing the simplicity and guaranteed behavior of the process, then delves into the usage and features of counters in the collections module, culminating in the creation of an ordered counter using inheritance.', 'duration': 105.163, 'highlights': ['The chapter discusses the simplicity and guaranteed behavior of dependency injection in Python using mock classes. The process of dependency injection with a mock class is highlighted as being easy to do with just one line of code, while also being guaranteed behavior.', 'The usage and features of counters in the collections module are demonstrated, including their subclass relationship with dict and their purpose of counting things. The transcript explains the nature of counters as a subclass of dict and their function of counting things, along with the mention of their association with the collections module.', 'The creation of an ordered counter is showcased through inheritance from counter and order dict, providing a solution to the dilemma of order versus counting in Python. The process of creating an ordered counter is highlighted as a solution to the trade-off between order and counting, achieved through inheritance from counter and order dict.']}, {'end': 1799.351, 'start': 1699.788, 'title': 'Ordered counter in python', 'summary': 'Demonstrates how to create an ordered counter in python using the order dict, resulting in a one-line code implementation with specific examples and challenges to the audience.', 'duration': 99.563, 'highlights': ['The chapter explains how to guarantee a particular order of calls in Python by using the order dict to create an ordered counter, resulting in a remarkably easy one-line composition.', 'It emphasizes the importance of making classes look nice and pickleable, and presents a demonstration of how the modified class produces an order dict, showcasing the practical application of the concept.', 'The speaker showcases the practical implementation of an ordered counter in Python, highlighting its functionality through specific examples and challenges to the audience, thus reinforcing the learning experience.']}], 'duration': 205.226, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/EiOglTERPEo/pics/EiOglTERPEo1594125.jpg', 'highlights': ['The chapter discusses the simplicity and guaranteed behavior of dependency injection in Python using mock classes.', 'The creation of an ordered counter is showcased through inheritance from counter and order dict, providing a solution to the dilemma of order versus counting in Python.', 'The chapter explains how to guarantee a particular order of calls in Python by using the order dict to create an ordered counter, resulting in a remarkably easy one-line composition.', 'The usage and features of counters in the collections module are demonstrated, including their subclass relationship with dict and their purpose of counting things.', 'The speaker showcases the practical implementation of an ordered counter in Python, highlighting its functionality through specific examples and challenges to the audience, thus reinforcing the learning experience.']}, {'end': 2662.296, 'segs': [{'end': 1865.964, 'src': 'heatmap', 'start': 1824.328, 'weight': 0.722, 'content': [{'end': 1830.052, 'text': 'Would you just like to know the couple things? Children get called before their parents and parents get called in the order listed.', 'start': 1824.328, 'duration': 5.724}, {'end': 1831.801, 'text': 'Up here.', 'start': 1831.121, 'duration': 0.68}, {'end': 1833.202, 'text': 'who gets called first?', 'start': 1831.801, 'duration': 1.401}, {'end': 1837.424, 'text': 'the ordered counter or the counter or the ordered dict??', 'start': 1833.202, 'duration': 4.222}, {'end': 1837.965, 'text': "Who's first??", 'start': 1837.464, 'duration': 0.501}, {'end': 1843.007, 'text': 'Ordered counter because children go before their parents.', 'start': 1839.465, 'duration': 3.542}, {'end': 1856.562, 'text': 'Okay? Now, what about the parents? Who comes first, the counter or the ordered dict? Counter, the parents stay in the order listed.', 'start': 1843.027, 'duration': 13.535}, {'end': 1865.964, 'text': "There's one other rule for the linearization algorithm, but it's important in practice, but not important for you to remember.", 'start': 1857.162, 'duration': 8.802}], 'summary': 'The ordered counter is called before the parents, as per the linearization algorithm.', 'duration': 41.636, 'max_score': 1824.328, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/EiOglTERPEo/pics/EiOglTERPEo1824328.jpg'}, {'end': 1865.964, 'src': 'embed', 'start': 1839.465, 'weight': 0, 'content': [{'end': 1843.007, 'text': 'Ordered counter because children go before their parents.', 'start': 1839.465, 'duration': 3.542}, {'end': 1856.562, 'text': 'Okay? Now, what about the parents? Who comes first, the counter or the ordered dict? Counter, the parents stay in the order listed.', 'start': 1843.027, 'duration': 13.535}, {'end': 1865.964, 'text': "There's one other rule for the linearization algorithm, but it's important in practice, but not important for you to remember.", 'start': 1857.162, 'duration': 8.802}], 'summary': 'Counter comes before ordered dict in linearization algorithm', 'duration': 26.499, 'max_score': 1839.465, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/EiOglTERPEo/pics/EiOglTERPEo1839465.jpg'}, {'end': 1935.025, 'src': 'embed', 'start': 1887.63, 'weight': 1, 'content': [{'end': 1891.812, 'text': 'What does super mean? It should have been called the next one in the line.', 'start': 1887.63, 'duration': 4.182}, {'end': 1897.374, 'text': "What's the word that means make into a line? Linearization.", 'start': 1894.133, 'duration': 3.241}, {'end': 1902.877, 'text': 'What are the only things you need to remember about linearization? Children come before parents, and parents stay in order.', 'start': 1897.754, 'duration': 5.123}, {'end': 1907.018, 'text': 'With that rule, you can force the line to be in the right order.', 'start': 1903.537, 'duration': 3.481}, {'end': 1913.44, 'text': 'Easy peasy? So it means next in line.', 'start': 1907.679, 'duration': 5.761}, {'end': 1915.421, 'text': 'Think of that every time you think of super.', 'start': 1913.58, 'duration': 1.841}, {'end': 1917.821, 'text': 'It does not mean call your parents.', 'start': 1915.701, 'duration': 2.12}, {'end': 1922.563, 'text': "Do you think it's pretty easy to talk to the next person in line? Yes.", 'start': 1918.242, 'duration': 4.321}, {'end': 1930.244, 'text': 'What is cooperative multiple inheritance? Cooperative multiple inheritance is where you design a tree of classes where everybody is cooperating.', 'start': 1923.043, 'duration': 7.201}, {'end': 1935.025, 'text': 'And what kind of cooperation is required? That everybody says next in line.', 'start': 1930.564, 'duration': 4.461}], 'summary': 'Super means next in line, with cooperation and order. linearization is key for inheritance.', 'duration': 47.395, 'max_score': 1887.63, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/EiOglTERPEo/pics/EiOglTERPEo1887630.jpg'}, {'end': 1974.142, 'src': 'heatmap', 'start': 1936.246, 'weight': 0.938, 'content': [{'end': 1946.075, 'text': "Is multiple inheritance with diamond diagrams easy or hard? Well, we said if there's no conflicts, it's easy.", 'start': 1936.246, 'duration': 9.829}, {'end': 1949.038, 'text': "And we said if it's single inheritance, it's easy.", 'start': 1946.876, 'duration': 2.162}, {'end': 1951.561, 'text': 'But everybody thinks of the other case as hard.', 'start': 1949.459, 'duration': 2.102}, {'end': 1952.823, 'text': "It's not hard.", 'start': 1952.082, 'duration': 0.741}, {'end': 1974.142, 'text': "It was a battery problem, wasn't it? The article, Super Considered Harmful, suggested it was a hard problem.", 'start': 1968.581, 'duration': 5.561}], 'summary': 'Multiple inheritance with diamond diagrams is easy if no conflicts, but perceived as hard. super considered harmful article suggested it as a hard problem.', 'duration': 37.896, 'max_score': 1936.246, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/EiOglTERPEo/pics/EiOglTERPEo1936246.jpg'}, {'end': 2284.753, 'src': 'embed', 'start': 2258.26, 'weight': 6, 'content': [{'end': 2262.781, 'text': 'When a class is designed non-cooperatively, Like Thomas here.', 'start': 2258.26, 'duration': 4.521}, {'end': 2271.426, 'text': 'The answer is you make another class whose sole job is hand it to Thomas, let him do his work, and then pass it along.', 'start': 2263.681, 'duration': 7.745}, {'end': 2273.887, 'text': 'Easy enough? Okay.', 'start': 2272.106, 'duration': 1.781}, {'end': 2280.811, 'text': "And so one of the problems mentioned in Super Considered Harmful is it doesn't work with classes that weren't designed cooperatively.", 'start': 2274.547, 'duration': 6.264}, {'end': 2282.072, 'text': 'It does work perfectly.', 'start': 2281.171, 'duration': 0.901}, {'end': 2284.753, 'text': 'You just have to put an extra cooperating class in front of it.', 'start': 2282.132, 'duration': 2.621}], 'summary': 'Non-cooperative classes solved by adding cooperating class in front.', 'duration': 26.493, 'max_score': 2258.26, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/EiOglTERPEo/pics/EiOglTERPEo2258260.jpg'}, {'end': 2407.271, 'src': 'embed', 'start': 2378.039, 'weight': 5, 'content': [{'end': 2380.521, 'text': "when you're using Super for cooperative multiple inheritance,", 'start': 2378.039, 'duration': 2.482}, {'end': 2386.527, 'text': "use keyword arguments because you can't know in advance who you're calling and you don't know what arguments they're going to need.", 'start': 2380.521, 'duration': 6.006}, {'end': 2389.751, 'text': "They know which ones they need, but they don't know who they're calling in advance.", 'start': 2386.808, 'duration': 2.943}, {'end': 2395.823, 'text': "For this to work, you can't have a Thomas in the middle who doesn't pass it along.", 'start': 2391.38, 'duration': 4.443}, {'end': 2399.806, 'text': 'But you can make a wrapper around Thomas that is cooperative.', 'start': 2396.263, 'duration': 3.543}, {'end': 2401.327, 'text': "It's a trivially easy thing to do.", 'start': 2399.966, 'duration': 1.361}, {'end': 2404.729, 'text': 'Just make a subclass that has a super in it.', 'start': 2401.787, 'duration': 2.942}, {'end': 2407.271, 'text': 'And remember, this is a chain of calls.', 'start': 2405.289, 'duration': 1.982}], 'summary': 'Use keyword arguments for cooperative multiple inheritance in super, ensuring all methods pass along necessary arguments.', 'duration': 29.232, 'max_score': 2378.039, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/EiOglTERPEo/pics/EiOglTERPEo2378039.jpg'}, {'end': 2533.111, 'src': 'heatmap', 'start': 2501.751, 'weight': 0.738, 'content': [{'end': 2505.032, 'text': 'when we call super, it goes up one level to pizza.', 'start': 2501.751, 'duration': 3.281}, {'end': 2509.273, 'text': "or I'm sorry, starting with pizza, we go up one level to dough factory and the next one goes to object.", 'start': 2505.032, 'duration': 4.241}, {'end': 2516.716, 'text': "If you don't need the next one in line, if anybody in line would do, if you'd like to start over again at the beginning, use self.", 'start': 2510.213, 'duration': 6.503}, {'end': 2519.417, 'text': "If you'd like the next in line, use super.", 'start': 2517.156, 'duration': 2.261}, {'end': 2526.949, 'text': 'Does that make sense? Every time you do self dot, the chain of lookups starts from the bottom and works its way up again.', 'start': 2519.777, 'duration': 7.172}, {'end': 2528.77, 'text': 'Super says next in line.', 'start': 2527.409, 'duration': 1.361}, {'end': 2533.111, 'text': 'So in this chain here, if we called self, it would have started all over again.', 'start': 2529.31, 'duration': 3.801}], 'summary': "Using 'super' goes up one level in the chain of lookups for object-oriented programming.", 'duration': 31.36, 'max_score': 2501.751, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/EiOglTERPEo/pics/EiOglTERPEo2501751.jpg'}], 'start': 1801.155, 'title': 'Understanding linearization algorithm and super in python', 'summary': "Explains the linearization algorithm in python, emphasizing the rules for method resolution order and the meaning of 'super', with a focus on cooperative multiple inheritance and its implications. it also discusses the problems with using the super keyword in python, highlighting the challenges faced in calling the next person in line, the need for cooperative multiple inheritance, and the use of keyword arguments to address unexpected arguments. the chapter emphasizes the importance of wrapping non-cooperative classes and the distinction between using 'super' and 'self' for method resolution.", 'chapters': [{'end': 1976.883, 'start': 1801.155, 'title': 'Understanding linearization algorithm and super in python', 'summary': "Explains the linearization algorithm in python, emphasizing the rules for method resolution order and the meaning of 'super', with a focus on cooperative multiple inheritance and its implications.", 'duration': 175.728, 'highlights': ["The linearization algorithm in Python ensures that children get called before their parents and parents get called in the order listed, with the order being stable to prevent scrambling of parents' orders. Children before parents, stable order, preventing scrambling of parents' orders", "The meaning of 'super' in Python is to call the next one in line, emphasizing the concept of linearization to force the line to be in the right order. Linearization concept, enforcing the right order", "Cooperative multiple inheritance in Python involves designing a tree of classes where cooperation is required for everyone to be 'next in line'. Cooperation in class tree design, 'next in line' concept", 'The complexity of multiple inheritance in Python is clarified, with the emphasis on cooperative behavior and the rules governing the method resolution order. Clarification of multiple inheritance complexity, rules for method resolution order']}, {'end': 2662.296, 'start': 1977.643, 'title': 'Understanding super in python', 'summary': "Discusses the problems with using the super keyword in python, highlighting the challenges faced in calling the next person in line, the need for cooperative multiple inheritance, and the use of keyword arguments to address unexpected arguments. the chapter also emphasizes the importance of wrapping non-cooperative classes and the distinction between using 'super' and 'self' for method resolution.", 'duration': 684.653, 'highlights': ['The need for cooperative multiple inheritance when using the super keyword is highlighted, along with the challenge of calling the next person in line. The chapter emphasizes the importance of cooperative multiple inheritance when using the super keyword, highlighting the challenge of calling the next person in line and the need for cooperation among classes.', 'The use of keyword arguments to address unexpected arguments is emphasized, showcasing the importance of using keyword arguments for cooperative multiple inheritance. The chapter underscores the use of keyword arguments to address unexpected arguments, particularly in the context of cooperative multiple inheritance, emphasizing the importance of using keyword arguments for cooperative multiple inheritance.', "The significance of wrapping non-cooperative classes and the distinction between using 'super' and 'self' for method resolution is highlighted. The chapter highlights the significance of wrapping non-cooperative classes and differentiates between using 'super' and 'self' for method resolution, emphasizing the importance of wrapping non-cooperative classes and the distinction between 'super' and 'self' for method resolution."]}], 'duration': 861.141, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/EiOglTERPEo/pics/EiOglTERPEo1801155.jpg', 'highlights': ["The linearization algorithm in Python ensures stable order, preventing scrambling of parents' orders.", "The meaning of 'super' in Python is to enforce the right order through linearization concept.", "Cooperative multiple inheritance in Python involves cooperation in class tree design and the 'next in line' concept.", 'The complexity of multiple inheritance in Python is clarified, emphasizing cooperative behavior and method resolution order rules.', 'The need for cooperative multiple inheritance when using the super keyword is highlighted, emphasizing the challenge of calling the next person in line.', 'The use of keyword arguments to address unexpected arguments is emphasized, showcasing its importance for cooperative multiple inheritance.', "The significance of wrapping non-cooperative classes and the distinction between using 'super' and 'self' for method resolution is highlighted."]}], 'highlights': ['The speaker emphasizes the significance of not repeating oneself (DRY) in coding, stressing the importance of reducing redundancy in the code to enhance its efficiency.', "The importance of linearization in Python inheritance is emphasized, as it determines the order of visiting everyone and how the super function behaves in calling the next in line rather than the caller's parents.", 'The process of subclassing makes the robot programmable and enables it to perform specific tasks, as demonstrated by the creation of a sweeping robot using the subclassing approach.', 'The chapter discusses the simplicity and guaranteed behavior of dependency injection in Python using mock classes.', "The intentional design of the 'super' keyword and the C3 linearization algorithm allows for specific modifications in the inheritance chain, demonstrating the deliberate and intentional nature of the process."]}