[ { "text": "[Music]", "start": 3.41, "duration": 9.829 }, { "text": "[Music]", "start": 15.28, "duration": 6.869 }, { "text": "all right this is cs50's Introduction to", "start": 24.08, "duration": 4.48 }, { "text": "programming with python my name is David", "start": 26.679, "duration": 3.641 }, { "text": "men and this is our week on object", "start": 28.56, "duration": 4.92 }, { "text": "oriented programming or o it turns out", "start": 30.32, "duration": 4.64 }, { "text": "that in the world of programming there's", "start": 33.48, "duration": 3.239 }, { "text": "different paradigms of programming", "start": 34.96, "duration": 3.84 }, { "text": "languages there's different ways of", "start": 36.719, "duration": 3.921 }, { "text": "solving problems with code and it's a", "start": 38.8, "duration": 3.16 }, { "text": "little hard to see this at first if", "start": 40.64, "duration": 3.36 }, { "text": "you've only learned one language but", "start": 41.96, "duration": 4.0 }, { "text": "over time if and when you learn other", "start": 44.0, "duration": 3.92 }, { "text": "languages besides python you'll start to", "start": 45.96, "duration": 3.4 }, { "text": "notice certain patterns and certain", "start": 47.92, "duration": 3.319 }, { "text": "capabilities of some languages but not", "start": 49.36, "duration": 4.44 }, { "text": "another thus far within the world of", "start": 51.239, "duration": 4.081 }, { "text": "python you and I have largely been", "start": 53.8, "duration": 4.2 }, { "text": "writing code that's procedural in nature", "start": 55.32, "duration": 4.199 }, { "text": "whereby we're writing procedures we're", "start": 58.0, "duration": 3.199 }, { "text": "writing functions and we're sort of", "start": 59.519, "duration": 4.121 }, { "text": "doing things top to bottom everything is", "start": 61.199, "duration": 4.441 }, { "text": "step by step by step as you would expect", "start": 63.64, "duration": 4.04 }, { "text": "in general from an algorithm but along", "start": 65.64, "duration": 3.6 }, { "text": "the way we've actually dabbled in", "start": 67.68, "duration": 3.52 }, { "text": "another Paradigm known as functional", "start": 69.24, "duration": 4.68 }, { "text": "programming with python whereby we've", "start": 71.2, "duration": 4.64 }, { "text": "been able to pass functions around we", "start": 73.92, "duration": 3.76 }, { "text": "even had an anonymous function some", "start": 75.84, "duration": 4.36 }, { "text": "weeks ago and that's evidence of", "start": 77.68, "duration": 4.439 }, { "text": "features of a functional programming", "start": 80.2, "duration": 2.879 }, { "text": "language even though we've just", "start": 82.119, "duration": 3.201 }, { "text": "scratched the surface thereof today we", "start": 83.079, "duration": 4.0 }, { "text": "focus on another Paradigm and this one", "start": 85.32, "duration": 4.04 }, { "text": "in more detail namely object-oriented", "start": 87.079, "duration": 4.161 }, { "text": "programming and now while some of you", "start": 89.36, "duration": 3.439 }, { "text": "might have prior programming experience", "start": 91.24, "duration": 3.159 }, { "text": "and have learned languages like Java", "start": 92.799, "duration": 4.28 }, { "text": "which are by Design fundamentally", "start": 94.399, "duration": 4.801 }, { "text": "objectoriented python indeed allows you", "start": 97.079, "duration": 4.04 }, { "text": "a bit of flexibility when it comes to", "start": 99.2, "duration": 4.279 }, { "text": "how you solve problems with code but it", "start": 101.119, "duration": 4.761 }, { "text": "turns out oop object-oriented", "start": 103.479, "duration": 4.041 }, { "text": "programming is a pretty compelling", "start": 105.88, "duration": 4.04 }, { "text": "solution to problems that you invariably", "start": 107.52, "duration": 4.52 }, { "text": "encounter as your programs get longer", "start": 109.92, "duration": 4.76 }, { "text": "larger and more complicated so indeed", "start": 112.04, "duration": 4.64 }, { "text": "oop for our purposes is going to be a", "start": 114.68, "duration": 4.68 }, { "text": "solution to a problem that builds on so", "start": 116.68, "duration": 4.68 }, { "text": "many of the lessons passed so let's go", "start": 119.36, "duration": 4.2 }, { "text": "ahead and do this let's start by writing", "start": 121.36, "duration": 4.88 }, { "text": "a program very procedurally by opening", "start": 123.56, "duration": 4.6 }, { "text": "up vs code here I'm going to go ahead", "start": 126.24, "duration": 4.799 }, { "text": "and create a program called student. py", "start": 128.16, "duration": 4.439 }, { "text": "and in this program I want to do", "start": 131.039, "duration": 4.48 }, { "text": "something relatively simple initially uh", "start": 132.599, "duration": 5.0 }, { "text": "as we might have done some weeks ago now", "start": 135.519, "duration": 4.601 }, { "text": "where I just ask a user for their name", "start": 137.599, "duration": 4.201 }, { "text": "and maybe in the context of the Harry", "start": 140.12, "duration": 3.68 }, { "text": "Potter Universe their house and just", "start": 141.8, "duration": 4.68 }, { "text": "print out where that student is from and", "start": 143.8, "duration": 4.719 }, { "text": "let's gradually enhance this program by", "start": 146.48, "duration": 3.92 }, { "text": "adding more and more features to it and", "start": 148.519, "duration": 4.561 }, { "text": "see if we don't stumble upon problems", "start": 150.4, "duration": 4.04 }, { "text": "that up until now we might not have had", "start": 153.08, "duration": 3.799 }, { "text": "very elegant well-designed solutions to", "start": 154.44, "duration": 4.32 }, { "text": "but if we introduce explicitly", "start": 156.879, "duration": 3.44 }, { "text": "object-oriented programming as a", "start": 158.76, "duration": 3.64 }, { "text": "programming technique I bet we can clean", "start": 160.319, "duration": 4.241 }, { "text": "up our code and set the stage for", "start": 162.4, "duration": 3.96 }, { "text": "writing even more sophisticated programs", "start": 164.56, "duration": 3.8 }, { "text": "longer programs down the line so in", "start": 166.36, "duration": 4.32 }, { "text": "student. piy let me go ahead and do a", "start": 168.36, "duration": 4.72 }, { "text": "name variable setting it equal to the", "start": 170.68, "duration": 4.32 }, { "text": "return value of input and just prompt", "start": 173.08, "duration": 4.2 }, { "text": "the user for their name like this and", "start": 175.0, "duration": 3.8 }, { "text": "then let me go ahead and do the same for", "start": 177.28, "duration": 3.319 }, { "text": "a house variable and and prompt the user", "start": 178.8, "duration": 4.24 }, { "text": "for their house using input like this", "start": 180.599, "duration": 4.64 }, { "text": "and let's do something super simple now", "start": 183.04, "duration": 4.16 }, { "text": "let's just go ahead and print out an F", "start": 185.239, "duration": 4.801 }, { "text": "string that says something like name", "start": 187.2, "duration": 5.24 }, { "text": "from house just so that I can confirm", "start": 190.04, "duration": 4.0 }, { "text": "that the contents of these variables are", "start": 192.44, "duration": 3.28 }, { "text": "indeed as I expect I'm not going to do", "start": 194.04, "duration": 3.08 }, { "text": "any error checking or trimming or", "start": 195.72, "duration": 2.72 }, { "text": "anything like that for now I'm really", "start": 197.12, "duration": 2.72 }, { "text": "just going to spit back out whatever the", "start": 198.44, "duration": 3.6 }, { "text": "user just typed in all right let me go", "start": 199.84, "duration": 4.64 }, { "text": "ahead and run python of student doy", "start": 202.04, "duration": 4.88 }, { "text": "let's use our go-to like Harry as in", "start": 204.48, "duration": 4.88 }, { "text": "Harry Potter from Gryffindor and when I", "start": 206.92, "duration": 4.519 }, { "text": "hit ENT now let's see if I see that", "start": 209.36, "duration": 4.72 }, { "text": "Harry from Gryffindor is indeed the case", "start": 211.439, "duration": 4.121 }, { "text": "all right so I think we have a working", "start": 214.08, "duration": 3.56 }, { "text": "program at this point but let's now", "start": 215.56, "duration": 3.759 }, { "text": "introduce some of those Lessons Learned", "start": 217.64, "duration": 3.4 }, { "text": "way back from week zero where we started", "start": 219.319, "duration": 3.401 }, { "text": "writing our own functions not", "start": 221.04, "duration": 4.0 }, { "text": "necessarily because it solves the", "start": 222.72, "duration": 4.079 }, { "text": "problem more correctly I dare say this", "start": 225.04, "duration": 4.399 }, { "text": "is correct as is but it begins to give", "start": 226.799, "duration": 5.121 }, { "text": "us building blocks that we can extend so", "start": 229.439, "duration": 4.8 }, { "text": "as to solve more complicated programs so", "start": 231.92, "duration": 5.12 }, { "text": "let me go back up to student. and let's", "start": 234.239, "duration": 4.64 }, { "text": "go ahead now and do this let's put the", "start": 237.04, "duration": 4.119 }, { "text": "entire log IC I just wrote inside of our", "start": 238.879, "duration": 4.2 }, { "text": "typical method called Main and let me", "start": 241.159, "duration": 3.72 }, { "text": "indent those three lines so that at", "start": 243.079, "duration": 3.641 }, { "text": "least they're now combined into one main", "start": 244.879, "duration": 5.161 }, { "text": "method but instead of using input on", "start": 246.72, "duration": 5.76 }, { "text": "line two and input on line three why", "start": 250.04, "duration": 3.72 }, { "text": "don't we go ahead and assume for the", "start": 252.48, "duration": 2.72 }, { "text": "moment that we've got some function", "start": 253.76, "duration": 3.719 }, { "text": "called get name in the world and let's", "start": 255.2, "duration": 3.52 }, { "text": "go ahead and assume we've got another", "start": 257.479, "duration": 2.841 }, { "text": "function like get house in the world", "start": 258.72, "duration": 3.6 }, { "text": "that don't take parameters but their", "start": 260.32, "duration": 4.0 }, { "text": "purpose in life is by their named going", "start": 262.32, "duration": 4.08 }, { "text": "to be to get the user's name and to get", "start": 264.32, "duration": 4.48 }, { "text": "their user's house respectively and then", "start": 266.4, "duration": 4.48 }, { "text": "I'm going to print out the exact same F", "start": 268.8, "duration": 4.119 }, { "text": "string as before I of course need to", "start": 270.88, "duration": 3.72 }, { "text": "implement these functions now so let me", "start": 272.919, "duration": 3.401 }, { "text": "go lower in my file and Define a", "start": 274.6, "duration": 4.2 }, { "text": "function called getor name nothing in", "start": 276.32, "duration": 3.84 }, { "text": "these parentheses because it's not going", "start": 278.8, "duration": 3.2 }, { "text": "to take a parameter and I'm going to go", "start": 280.16, "duration": 4.16 }, { "text": "ahead and do something like name equals", "start": 282.0, "duration": 4.28 }, { "text": "input quote unquote name just like", "start": 284.32, "duration": 3.28 }, { "text": "before and then I'm going to go ahead", "start": 286.28, "duration": 3.52 }, { "text": "and return name so it's a super simple", "start": 287.6, "duration": 4.8 }, { "text": "function but it's a an abstraction I now", "start": 289.8, "duration": 4.679 }, { "text": "have a function called get name whose", "start": 292.4, "duration": 3.48 }, { "text": "implementation details I don't have to", "start": 294.479, "duration": 3.041 }, { "text": "care about anymore I just know that the", "start": 295.88, "duration": 3.36 }, { "text": "function exists and I can tighten this", "start": 297.52, "duration": 3.76 }, { "text": "up in in fact I don't really need a name", "start": 299.24, "duration": 4.12 }, { "text": "variable on line 8 if I'm immediately", "start": 301.28, "duration": 3.639 }, { "text": "going to return that same name variable", "start": 303.36, "duration": 3.8 }, { "text": "on line 9 so let me just tighten this up", "start": 304.919, "duration": 3.521 }, { "text": "a little bit even though it doesn't", "start": 307.16, "duration": 3.039 }, { "text": "change the functionality and just", "start": 308.44, "duration": 4.24 }, { "text": "immediately return the return value of", "start": 310.199, "duration": 5.641 }, { "text": "the inputs uh function call here let's", "start": 312.68, "duration": 5.72 }, { "text": "do something very similar now for get", "start": 315.84, "duration": 4.16 }, { "text": "house which will similarly take no", "start": 318.4, "duration": 3.12 }, { "text": "arguments I'm going to go ahead and", "start": 320.0, "duration": 3.72 }, { "text": "return the return value of input this", "start": 321.52, "duration": 4.0 }, { "text": "time prompting the user for their house", "start": 323.72, "duration": 4.199 }, { "text": "and I need one final detail at the very", "start": 325.52, "duration": 4.64 }, { "text": "bottom let's continue our habit of doing", "start": 327.919, "duration": 5.041 }, { "text": "if the name of this file equals equals", "start": 330.16, "duration": 5.479 }, { "text": "quote unquote main then let's go ahead", "start": 332.96, "duration": 4.84 }, { "text": "and actually call Main and recall that", "start": 335.639, "duration": 3.801 }, { "text": "we have that in place so that if this", "start": 337.8, "duration": 3.519 }, { "text": "eventually becomes part of a module a", "start": 339.44, "duration": 3.759 }, { "text": "library of sorts I don't accidentally", "start": 341.319, "duration": 5.201 }, { "text": "call Main blindly I only do it if I mean", "start": 343.199, "duration": 5.881 }, { "text": "to run main from the command line on", "start": 346.52, "duration": 4.88 }, { "text": "this file all right so if I didn't make", "start": 349.08, "duration": 4.52 }, { "text": "any mistakes here let me go ahead and in", "start": 351.4, "duration": 4.04 }, { "text": "my terminal window again run python of", "start": 353.6, "duration": 5.039 }, { "text": "student. piy enter let's type in Harry", "start": 355.44, "duration": 6.68 }, { "text": "enter let's type in Gryffindor enter and", "start": 358.639, "duration": 5.961 }, { "text": "we're set Harry from Gryffindor seems to", "start": 362.12, "duration": 4.479 }, { "text": "still be working so we haven't really", "start": 364.6, "duration": 4.879 }, { "text": "solved the problem any more correctly", "start": 366.599, "duration": 4.88 }, { "text": "but I've laid the foundation to maybe", "start": 369.479, "duration": 3.641 }, { "text": "now do some more interesting things", "start": 371.479, "duration": 3.401 }, { "text": "because I've have these building blocks", "start": 373.12, "duration": 4.84 }, { "text": "in place all right but let me propose", "start": 374.88, "duration": 5.319 }, { "text": "that we could be doing this a little bit", "start": 377.96, "duration": 4.88 }, { "text": "differently get name get house is fine", "start": 380.199, "duration": 4.0 }, { "text": "but at the end of the day I'm really", "start": 382.84, "duration": 3.6 }, { "text": "trying to get a student from the user I", "start": 384.199, "duration": 4.44 }, { "text": "want their name and their house not just", "start": 386.44, "duration": 3.68 }, { "text": "one or the other", "start": 388.639, "duration": 3.481 }, { "text": "so maybe it would be a little cleaner", "start": 390.12, "duration": 5.0 }, { "text": "still to define a function called get", "start": 392.12, "duration": 5.04 }, { "text": "student and let get student do all of", "start": 395.12, "duration": 4.799 }, { "text": "this work for us now theoretically get", "start": 397.16, "duration": 4.759 }, { "text": "student could call get name and could", "start": 399.919, "duration": 3.68 }, { "text": "call get house but because these", "start": 401.919, "duration": 4.161 }, { "text": "functions are so short I think I'm okay", "start": 403.599, "duration": 4.521 }, { "text": "with just defining one function called", "start": 406.08, "duration": 3.76 }, { "text": "get student that similarly won't take", "start": 408.12, "duration": 3.56 }, { "text": "any arguments but it's going to do two", "start": 409.84, "duration": 3.32 }, { "text": "things it's going to get the student's", "start": 411.68, "duration": 3.6 }, { "text": "name by prompting them with input as", "start": 413.16, "duration": 3.68 }, { "text": "before and it's going to get the", "start": 415.28, "duration": 3.56 }, { "text": "students house by also prompting them as", "start": 416.84, "duration": 3.079 }, { "text": "before", "start": 418.84, "duration": 4.88 }, { "text": "and then now hm I want to return the", "start": 419.919, "duration": 5.641 }, { "text": "student but I think I might have painted", "start": 423.72, "duration": 4.199 }, { "text": "myself into a corner here because I now", "start": 425.56, "duration": 4.759 }, { "text": "have two variables name and house and", "start": 427.919, "duration": 4.12 }, { "text": "yet up until now we've pretty much", "start": 430.319, "duration": 3.481 }, { "text": "returned one or the other we've returned", "start": 432.039, "duration": 4.641 }, { "text": "one value so any suggestions for how we", "start": 433.8, "duration": 4.959 }, { "text": "can perhaps solve this problem that I", "start": 436.68, "duration": 4.959 }, { "text": "just created for myself whereby I want", "start": 438.759, "duration": 5.521 }, { "text": "to return really a student but I", "start": 441.639, "duration": 5.481 }, { "text": "currently have a name variable and a", "start": 444.28, "duration": 4.639 }, { "text": "house variable I'd minimally like to", "start": 447.12, "duration": 4.199 }, { "text": "return both both of those I believe that", "start": 448.919, "duration": 4.921 }, { "text": "we can return a dictionary includes the", "start": 451.319, "duration": 4.801 }, { "text": "name and the house yeah so we absolutely", "start": 453.84, "duration": 4.28 }, { "text": "could return a dictionary a dict object", "start": 456.12, "duration": 4.919 }, { "text": "in Python whereby maybe one key is name", "start": 458.12, "duration": 4.759 }, { "text": "one key is house and the values thereof", "start": 461.039, "duration": 3.241 }, { "text": "are exactly the values of these", "start": 462.879, "duration": 3.961 }, { "text": "variables we could totally do that uh I", "start": 464.28, "duration": 4.0 }, { "text": "worry that that might be getting a", "start": 466.84, "duration": 3.039 }, { "text": "little complicated I wonder if there's a", "start": 468.28, "duration": 4.56 }, { "text": "simpler way instead any other instincts", "start": 469.879, "duration": 5.081 }, { "text": "even if you're not sure it would work", "start": 472.84, "duration": 4.52 }, { "text": "return both name and house return both", "start": 474.96, "duration": 4.16 }, { "text": "name and house I I like the sound of", "start": 477.36, "duration": 3.36 }, { "text": "that it sounds simple I don't have to", "start": 479.12, "duration": 3.079 }, { "text": "figure out what a dictionary is going to", "start": 480.72, "duration": 4.039 }, { "text": "look like and in fact this too would be", "start": 482.199, "duration": 4.28 }, { "text": "a valid approach even if you've not seen", "start": 484.759, "duration": 3.801 }, { "text": "this before it turns out in Python that", "start": 486.479, "duration": 5.041 }, { "text": "you can kind of return multiple values", "start": 488.56, "duration": 4.88 }, { "text": "but that's a bit of a white lie or we", "start": 491.52, "duration": 3.16 }, { "text": "could take Muhammad's approach of", "start": 493.44, "duration": 2.879 }, { "text": "actually returning a dictionary and", "start": 494.68, "duration": 3.639 }, { "text": "putting multiple Keys therein so here", "start": 496.319, "duration": 3.641 }, { "text": "again we have yet another example of how", "start": 498.319, "duration": 3.201 }, { "text": "you can solve the same problem in at", "start": 499.96, "duration": 3.04 }, { "text": "least two ways and I dare say we're", "start": 501.52, "duration": 4.359 }, { "text": "about to see even more so one way you", "start": 503.0, "duration": 4.919 }, { "text": "could solve this problem whereby you", "start": 505.879, "duration": 5.04 }, { "text": "want to return multiple values would be", "start": 507.919, "duration": 5.441 }, { "text": "to do something like this I could go", "start": 510.919, "duration": 5.441 }, { "text": "ahead and literally return not just name", "start": 513.36, "duration": 5.4 }, { "text": "but I could put a comma and also return", "start": 516.36, "duration": 4.0 }, { "text": "house this is not necessarily something", "start": 518.76, "duration": 3.44 }, { "text": "you can do in other languages if you", "start": 520.36, "duration": 3.359 }, { "text": "have programmed in other languages", "start": 522.2, "duration": 3.68 }, { "text": "before it depends on the language but it", "start": 523.719, "duration": 4.881 }, { "text": "looks like thanks to this comma maybe I", "start": 525.88, "duration": 4.84 }, { "text": "can in fact return two values as", "start": 528.6, "duration": 4.76 }, { "text": "actually proposed well if I'm returning", "start": 530.72, "duration": 5.04 }, { "text": "two values in this way on line 10 how do", "start": 533.36, "duration": 4.64 }, { "text": "I get both values at the same time well", "start": 535.76, "duration": 4.4 }, { "text": "there's a couple of ways let me go up to", "start": 538.0, "duration": 4.959 }, { "text": "my main function I know minimally I'm", "start": 540.16, "duration": 4.239 }, { "text": "going to have to change the get name and", "start": 542.959, "duration": 3.521 }, { "text": "get house to get student but what am I", "start": 544.399, "duration": 5.241 }, { "text": "going to store the return value in I", "start": 546.48, "duration": 5.28 }, { "text": "think I could actually do this and we", "start": 549.64, "duration": 3.96 }, { "text": "have seen this technique before where", "start": 551.76, "duration": 4.36 }, { "text": "you can unpack so to speak sequences of", "start": 553.6, "duration": 4.6 }, { "text": "values that are coming back and indeed", "start": 556.12, "duration": 4.52 }, { "text": "consider this to be exactly that name", "start": 558.2, "duration": 4.319 }, { "text": "comma house is some kind of sequence", "start": 560.64, "duration": 3.84 }, { "text": "that I'm returning of values name comma", "start": 562.519, "duration": 3.88 }, { "text": "house so if I want to unpack those and", "start": 564.48, "duration": 3.68 }, { "text": "store the return values in two separate", "start": 566.399, "duration": 4.401 }, { "text": "variables I can in fact use the commas", "start": 568.16, "duration": 4.6 }, { "text": "on the left hand side of my assignment", "start": 570.8, "duration": 4.52 }, { "text": "operator the equal sign to do just that", "start": 572.76, "duration": 4.84 }, { "text": "now to be clear I don't need to call", "start": 575.32, "duration": 4.84 }, { "text": "these variables name and house here I", "start": 577.6, "duration": 4.799 }, { "text": "could simplify this and use just n here", "start": 580.16, "duration": 4.84 }, { "text": "and H here and then I could return just", "start": 582.399, "duration": 5.921 }, { "text": "n and H but I would argue that's not", "start": 585.0, "duration": 5.839 }, { "text": "very uh clear to the reader as to what's", "start": 588.32, "duration": 4.28 }, { "text": "going on so I think in this case even", "start": 590.839, "duration": 3.24 }, { "text": "though it's a coincidence that I've used", "start": 592.6, "duration": 3.28 }, { "text": "the same variable names in get student", "start": 594.079, "duration": 4.241 }, { "text": "and get Main and in main it's a little", "start": 595.88, "duration": 4.0 }, { "text": "more readable to someone like me so I'm", "start": 598.32, "duration": 3.759 }, { "text": "going to leave it as is well let's go", "start": 599.88, "duration": 4.24 }, { "text": "ahead and see now if this works let me", "start": 602.079, "duration": 3.601 }, { "text": "clear my screen down here and run python", "start": 604.12, "duration": 3.76 }, { "text": "of student. enter let's again type in", "start": 605.68, "duration": 4.64 }, { "text": "Harry let's again type in Gryffindor", "start": 607.88, "duration": 5.519 }, { "text": "enter and voila we still see that Harry", "start": 610.32, "duration": 5.28 }, { "text": "is from Gryffindor but what are we", "start": 613.399, "duration": 4.321 }, { "text": "actually doing here what are we actually", "start": 615.6, "duration": 4.28 }, { "text": "doing by returning this value well it", "start": 617.72, "duration": 5.119 }, { "text": "turns out that what we've just done is", "start": 619.88, "duration": 5.959 }, { "text": "used a tupple a tupple is another type", "start": 622.839, "duration": 6.361 }, { "text": "of data in Python that's a collection of", "start": 625.839, "duration": 6.401 }, { "text": "values X comma y or X comma y comma Z", "start": 629.2, "duration": 5.16 }, { "text": "it's similar in spirit to a list in that", "start": 632.24, "duration": 4.92 }, { "text": "sense but it's immutable it's not", "start": 634.36, "duration": 4.8 }, { "text": "mutable now what does that mean a list", "start": 637.16, "duration": 3.52 }, { "text": "as we've seen it before is a data", "start": 639.16, "duration": 3.4 }, { "text": "structure in Python that you can change", "start": 640.68, "duration": 3.8 }, { "text": "the values of you can go into bracket", "start": 642.56, "duration": 4.0 }, { "text": "zero for the first location and change", "start": 644.48, "duration": 3.359 }, { "text": "the value there you can go to bracket", "start": 646.56, "duration": 2.92 }, { "text": "one bracket two bracket three and", "start": 647.839, "duration": 3.721 }, { "text": "actually change the values in lists but", "start": 649.48, "duration": 4.039 }, { "text": "if you have no intention of changing the", "start": 651.56, "duration": 3.719 }, { "text": "values of variables and you want to", "start": 653.519, "duration": 4.361 }, { "text": "return effectively multiple values you", "start": 655.279, "duration": 3.961 }, { "text": "don't have to even return it as as a", "start": 657.88, "duration": 3.48 }, { "text": "list you can return it as a tupple", "start": 659.24, "duration": 4.44 }, { "text": "instead just by using a comma and it", "start": 661.36, "duration": 4.44 }, { "text": "turns out we can make explicit that", "start": 663.68, "duration": 4.399 }, { "text": "here's the white lie I'm not actually", "start": 665.8, "duration": 5.2 }, { "text": "returning two values per se whenever you", "start": 668.079, "duration": 5.281 }, { "text": "use a comma in this way on line nine", "start": 671.0, "duration": 5.04 }, { "text": "you're actually returning one value", "start": 673.36, "duration": 5.52 }, { "text": "which is a tupple inside of that tupple", "start": 676.04, "duration": 4.72 }, { "text": "now are two values so it's similar in", "start": 678.88, "duration": 3.84 }, { "text": "spirit to returning one list with two", "start": 680.76, "duration": 4.8 }, { "text": "things here I'm returning one Tuple with", "start": 682.72, "duration": 4.52 }, { "text": "two things and the mere fact that I've", "start": 685.56, "duration": 3.839 }, { "text": "used a comma and nothing else tells", "start": 687.24, "duration": 3.599 }, { "text": "python that I indeed want to return a", "start": 689.399, "duration": 3.481 }, { "text": "tuple but there's more explicit syntax", "start": 690.839, "duration": 4.161 }, { "text": "that we can use instead I can actually", "start": 692.88, "duration": 5.199 }, { "text": "more verbosely put explicit parentheses", "start": 695.0, "duration": 5.56 }, { "text": "around the values of this tupple just to", "start": 698.079, "duration": 4.521 }, { "text": "make more clear to me to the reader that", "start": 700.56, "duration": 4.12 }, { "text": "this isn't two values per se this is one", "start": 702.6, "duration": 4.2 }, { "text": "value with two things inside of it and", "start": 704.68, "duration": 3.76 }, { "text": "what I can actually do then too is I", "start": 706.8, "duration": 3.76 }, { "text": "don't have to unpack this up here so to", "start": 708.44, "duration": 3.76 }, { "text": "speak I can actually go up here and", "start": 710.56, "duration": 4.36 }, { "text": "maybe give a more apt name like student", "start": 712.2, "duration": 5.48 }, { "text": "and I can name the value or rather name", "start": 714.92, "duration": 4.28 }, { "text": "the variable in which I'm storing the", "start": 717.68, "duration": 3.8 }, { "text": "return value of get student as quote", "start": 719.2, "duration": 4.72 }, { "text": "unquote student so maybe this is a", "start": 721.48, "duration": 4.12 }, { "text": "little better design now because I'm", "start": 723.92, "duration": 4.2 }, { "text": "sort of abstracting away what a student", "start": 725.6, "duration": 4.52 }, { "text": "is it's implemented at the moment as a", "start": 728.12, "duration": 4.12 }, { "text": "tupple with two values but at least now", "start": 730.12, "duration": 4.88 }, { "text": "I have a variable called what I mean a", "start": 732.24, "duration": 5.039 }, { "text": "student but there's going to be a catch", "start": 735.0, "duration": 4.399 }, { "text": "on line three I still want to print out", "start": 737.279, "duration": 4.56 }, { "text": "that Student's name and their house but", "start": 739.399, "duration": 4.281 }, { "text": "I don't have a name variable anymore and", "start": 741.839, "duration": 3.281 }, { "text": "I don't have a house and I also don't", "start": 743.68, "duration": 3.599 }, { "text": "have a dictionary as was proposed", "start": 745.12, "duration": 5.56 }, { "text": "earlier so I can't even go at those keys", "start": 747.279, "duration": 6.081 }, { "text": "by name but what a tupple is it's very", "start": 750.68, "duration": 4.88 }, { "text": "similar in spirit to a list but it is", "start": 753.36, "duration": 4.279 }, { "text": "indeed just immutable and what I mean by", "start": 755.56, "duration": 4.16 }, { "text": "that is I can still index into it", "start": 757.639, "duration": 4.961 }, { "text": "numerically by saying student square", "start": 759.72, "duration": 5.919 }, { "text": "bracket Z for the item in the first", "start": 762.6, "duration": 4.84 }, { "text": "location in that tupple and then over", "start": 765.639, "duration": 3.481 }, { "text": "here instead of house I can say student", "start": 767.44, "duration": 4.079 }, { "text": "bracket one student bracket one is going", "start": 769.12, "duration": 4.48 }, { "text": "to give me the second location in that", "start": 771.519, "duration": 3.641 }, { "text": "tupple let me go ahead and clear my", "start": 773.6, "duration": 3.56 }, { "text": "terminal window again run python of", "start": 775.16, "duration": 4.679 }, { "text": "student. let's type in Harry let's type", "start": 777.16, "duration": 5.72 }, { "text": "in Gryffindor enter and we still have", "start": 779.839, "duration": 5.68 }, { "text": "some working code let me pause here now", "start": 782.88, "duration": 5.639 }, { "text": "and see if there are any questions on", "start": 785.519, "duration": 6.32 }, { "text": "this technique of returning a tupple and", "start": 788.519, "duration": 6.32 }, { "text": "indexing into it in this way I guess", "start": 791.839, "duration": 5.161 }, { "text": "what's a like a actual use case where", "start": 794.839, "duration": 5.481 }, { "text": "you would use a tupple versus you know a", "start": 797.0, "duration": 5.16 }, { "text": "list or something else that's similar", "start": 800.32, "duration": 3.199 }, { "text": "it's a really good question when would", "start": 802.16, "duration": 3.4 }, { "text": "you use a tuple versus a list when you", "start": 803.519, "duration": 4.161 }, { "text": "want to program defensively or in", "start": 805.56, "duration": 4.279 }, { "text": "general when you know the values in this", "start": 807.68, "duration": 4.12 }, { "text": "variable shouldn't change so why would", "start": 809.839, "duration": 3.721 }, { "text": "you use a data type that allows them to", "start": 811.8, "duration": 4.64 }, { "text": "be changed it just invites mistakes bugs", "start": 813.56, "duration": 4.92 }, { "text": "down the line either by you or", "start": 816.44, "duration": 3.6 }, { "text": "colleagues who are interacting with your", "start": 818.48, "duration": 4.039 }, { "text": "code so tupple is just another way where", "start": 820.04, "duration": 4.799 }, { "text": "you can increase the probability of", "start": 822.519, "duration": 4.281 }, { "text": "correctness by just not letting anyone", "start": 824.839, "duration": 4.281 }, { "text": "yourself included change the contents", "start": 826.8, "duration": 4.399 }, { "text": "therein so it's just another tool in", "start": 829.12, "duration": 4.519 }, { "text": "your toolkit but let's make clear then", "start": 831.199, "duration": 4.681 }, { "text": "what I mean by immutable again I claim", "start": 833.639, "duration": 4.0 }, { "text": "that immutable means that you cannot", "start": 835.88, "duration": 4.04 }, { "text": "change the value well let's go ahead and", "start": 837.639, "duration": 4.44 }, { "text": "try to do this let me go ahead and run", "start": 839.92, "duration": 4.44 }, { "text": "this program once more as is python of", "start": 842.079, "duration": 6.241 }, { "text": "student. let me go ahead and type in for", "start": 844.36, "duration": 7.399 }, { "text": "instance uh how about uh padma's name", "start": 848.32, "duration": 4.439 }, { "text": "and I'm going to go ahead and say that", "start": 851.759, "duration": 3.241 }, { "text": "padma's in Gryffindor as in the movies", "start": 852.759, "duration": 4.601 }, { "text": "and we see Padma from Gryffindor but", "start": 855.0, "duration": 4.32 }, { "text": "technically I went down this rabbit hole", "start": 857.36, "duration": 4.2 }, { "text": "and looking at Harry Potter more closely", "start": 859.32, "duration": 4.28 }, { "text": "technically in the books Padma I believe", "start": 861.56, "duration": 4.16 }, { "text": "was from Ravenclaw so this is actually a", "start": 863.6, "duration": 3.799 }, { "text": "mistake or an inconsistency between the", "start": 865.72, "duration": 3.559 }, { "text": "movies and the books let's see if we", "start": 867.399, "duration": 4.281 }, { "text": "can't fix this inconsistency in our code", "start": 869.279, "duration": 4.881 }, { "text": "so how about we do this if the student's", "start": 871.68, "duration": 4.8 }, { "text": "name that's inputed equals Padma why", "start": 874.16, "duration": 5.08 }, { "text": "don't we override whatever the uh", "start": 876.48, "duration": 4.279 }, { "text": "whatever the house is and change it to", "start": 879.24, "duration": 4.599 }, { "text": "be properly Gryffindor let me go ahead", "start": 880.759, "duration": 5.88 }, { "text": "and do if student now if I want to get", "start": 883.839, "duration": 4.401 }, { "text": "at padma's name I'm going to have to do", "start": 886.639, "duration": 3.88 }, { "text": "student bracket zero I have to know what", "start": 888.24, "duration": 4.399 }, { "text": "location the name is in in this tupple", "start": 890.519, "duration": 5.361 }, { "text": "but if that in value equals equals Padma", "start": 892.639, "duration": 5.0 }, { "text": "let's go ahead with this if statement", "start": 895.88, "duration": 3.519 }, { "text": "and make a change let's change the", "start": 897.639, "duration": 4.801 }, { "text": "students F uh bracket one value so the", "start": 899.399, "duration": 5.24 }, { "text": "second value if we're zero indexing", "start": 902.44, "duration": 3.68 }, { "text": "let's change it to be another house in", "start": 904.639, "duration": 3.401 }, { "text": "the World of Harry Potter called", "start": 906.12, "duration": 4.88 }, { "text": "Ravenclaw so I'm just fixing maybe the", "start": 908.04, "duration": 4.479 }, { "text": "user's input they watch the movie so", "start": 911.0, "duration": 3.88 }, { "text": "they type in Padma Gryffindor but in the", "start": 912.519, "duration": 4.961 }, { "text": "books it was Padma from Ravenclaw all", "start": 914.88, "duration": 4.36 }, { "text": "right let me go ahead and go down to my", "start": 917.48, "duration": 4.56 }, { "text": "terminal window clear my uh terminal and", "start": 919.24, "duration": 5.08 }, { "text": "do python of student. enter I'm going to", "start": 922.04, "duration": 4.599 }, { "text": "do Harry as well as Gryffindor just to", "start": 924.32, "duration": 4.4 }, { "text": "demonstrate that that is still working", "start": 926.639, "duration": 4.32 }, { "text": "as intended Let Me Clear My screen again", "start": 928.72, "duration": 4.32 }, { "text": "though and run python of studenty on", "start": 930.959, "duration": 4.641 }, { "text": "Padma and I'll put her too in Gryffindor", "start": 933.04, "duration": 5.12 }, { "text": "as in the movies and hit enter and now I", "start": 935.6, "duration": 4.84 }, { "text": "just see a big mess of errors on the", "start": 938.16, "duration": 4.08 }, { "text": "screen some kind of exception has been", "start": 940.44, "duration": 4.079 }, { "text": "thrown and indeed a type error has", "start": 942.24, "duration": 4.279 }, { "text": "happened I'm using a data type wherein", "start": 944.519, "duration": 4.361 }, { "text": "there's an error and what is that error", "start": 946.519, "duration": 5.56 }, { "text": "well tupple object does not support item", "start": 948.88, "duration": 6.199 }, { "text": "assignment it's a little arcany Express", "start": 952.079, "duration": 4.801 }, { "text": "that is that's not really very user", "start": 955.079, "duration": 3.361 }, { "text": "friendly but if you think about what", "start": 956.88, "duration": 3.24 }, { "text": "those words mean Tuple object does not", "start": 958.44, "duration": 3.68 }, { "text": "support item assignment so assignment is", "start": 960.12, "duration": 4.12 }, { "text": "copying from right to left so somehow", "start": 962.12, "duration": 3.8 }, { "text": "that's invalid and here is a", "start": 964.24, "duration": 3.8 }, { "text": "manifestation of the", "start": 965.92, "duration": 5.08 }, { "text": "immutability of topples you cannot", "start": 968.04, "duration": 5.599 }, { "text": "change location zero or one or anything", "start": 971.0, "duration": 4.639 }, { "text": "inside that is a feature that is the", "start": 973.639, "duration": 5.041 }, { "text": "design of a tupple so if I want to", "start": 975.639, "duration": 4.68 }, { "text": "override that I think I'm going to have", "start": 978.68, "duration": 3.44 }, { "text": "to use a different type of data that", "start": 980.319, "duration": 3.801 }, { "text": "we've used before namely a list and", "start": 982.12, "duration": 4.04 }, { "text": "that's fine if you want to enable", "start": 984.12, "duration": 4.159 }, { "text": "yourself and colleagues using your code", "start": 986.16, "duration": 5.0 }, { "text": "to change the contents of that container", "start": 988.279, "duration": 4.961 }, { "text": "well we can go ahead and return not a", "start": 991.16, "duration": 4.799 }, { "text": "tupple using explicit parentheses or no", "start": 993.24, "duration": 4.959 }, { "text": "parentheses just the comma but I can use", "start": 995.959, "duration": 4.281 }, { "text": "square brackets and if I'm using square", "start": 998.199, "duration": 3.961 }, { "text": "brackets on the left and the right this", "start": 1000.24, "duration": 5.32 }, { "text": "is indeed explicitly a list same idea", "start": 1002.16, "duration": 5.84 }, { "text": "but it's mutable that is to say you can", "start": 1005.56, "duration": 4.959 }, { "text": "change the contents of a list so making", "start": 1008.0, "duration": 5.0 }, { "text": "no other changes just returning a list", "start": 1010.519, "duration": 4.961 }, { "text": "with square brackets instead of a tuple", "start": 1013.0, "duration": 4.839 }, { "text": "with parentheses or just the comma let", "start": 1015.48, "duration": 3.919 }, { "text": "me go ahead now and run python of", "start": 1017.839, "duration": 5.0 }, { "text": "studenty enter let me type in Harry and", "start": 1019.399, "duration": 6.121 }, { "text": "Gryffindor again that's still working", "start": 1022.839, "duration": 5.2 }, { "text": "good to see let me run this once more", "start": 1025.52, "duration": 5.24 }, { "text": "and type in Padma and Gryffindor as in", "start": 1028.039, "duration": 5.241 }, { "text": "the movies but no now we've corrected it", "start": 1030.76, "duration": 5.159 }, { "text": "to be Padma from Ravenclaw as in the", "start": 1033.28, "duration": 3.799 }, { "text": "books", "start": 1035.919, "duration": 4.241 }, { "text": "instead any questions now on tuples", "start": 1037.079, "duration": 5.72 }, { "text": "versus lists or this idea of", "start": 1040.16, "duration": 4.879 }, { "text": "immutability versus", "start": 1042.799, "duration": 6.521 }, { "text": "mutability uh can be used a nest cou in", "start": 1045.039, "duration": 7.88 }, { "text": "Python like a a nested list absolutely", "start": 1049.32, "duration": 5.4 }, { "text": "you can have not only nested lists in", "start": 1052.919, "duration": 3.681 }, { "text": "Python where one of the elements in a", "start": 1054.72, "duration": 3.839 }, { "text": "list could be another list so you have", "start": 1056.6, "duration": 3.64 }, { "text": "some square brackets out here you might", "start": 1058.559, "duration": 3.401 }, { "text": "have some other square brackets inside", "start": 1060.24, "duration": 3.24 }, { "text": "you can absolutely do the same with a", "start": 1061.96, "duration": 3.839 }, { "text": "tuple as well there's no constraint on", "start": 1063.48, "duration": 4.319 }, { "text": "the types of values you can put in there", "start": 1065.799, "duration": 3.801 }, { "text": "we've not had occasion to do that in", "start": 1067.799, "duration": 4.641 }, { "text": "this case I'm just returning a simple uh", "start": 1069.6, "duration": 4.88 }, { "text": "simple tupple with two elements but yes", "start": 1072.44, "duration": 4.2 }, { "text": "you could absolutely do that too other", "start": 1074.48, "duration": 4.8 }, { "text": "questions on tupples versus lists", "start": 1076.64, "duration": 4.88 }, { "text": "okay for example um when I see the", "start": 1079.28, "duration": 4.8 }, { "text": "square bracket um is it mainly used for", "start": 1081.52, "duration": 5.639 }, { "text": "the list oh a really good question uh", "start": 1084.08, "duration": 6.76 }, { "text": "sort of so when you create a value like", "start": 1087.159, "duration": 5.441 }, { "text": "a list you use square brackets and that", "start": 1090.84, "duration": 3.199 }, { "text": "would indeed be a visual indicator that", "start": 1092.6, "duration": 4.079 }, { "text": "this is definitely a list uh if you", "start": 1094.039, "duration": 4.441 }, { "text": "instead see parentheses that's a visual", "start": 1096.679, "duration": 3.641 }, { "text": "indicator when creating a value that", "start": 1098.48, "duration": 4.8 }, { "text": "it's definitely a tuple however somewhat", "start": 1100.32, "duration": 6.44 }, { "text": "confusingly both lists and topples use", "start": 1103.28, "duration": 6.0 }, { "text": "square brackets when you access the", "start": 1106.76, "duration": 4.68 }, { "text": "contents of them when you index into", "start": 1109.28, "duration": 4.759 }, { "text": "them at location zero or location one", "start": 1111.44, "duration": 5.0 }, { "text": "you always use square brackets so that's", "start": 1114.039, "duration": 4.841 }, { "text": "the distinction there good question", "start": 1116.44, "duration": 4.4 }, { "text": "allow me to propose now if I may that we", "start": 1118.88, "duration": 4.12 }, { "text": "solve this problem yet another way and", "start": 1120.84, "duration": 3.76 }, { "text": "let's see if we're either making things", "start": 1123.0, "duration": 4.039 }, { "text": "better or for worse than us recall that", "start": 1124.6, "duration": 4.6 }, { "text": "dictionaries or dict objects also exist", "start": 1127.039, "duration": 3.961 }, { "text": "in python and a dictionary is this", "start": 1129.2, "duration": 4.28 }, { "text": "collection of keys and values and the", "start": 1131.0, "duration": 4.559 }, { "text": "upside in particular of a dictionary is", "start": 1133.48, "duration": 3.48 }, { "text": "that they have better semantics right", "start": 1135.559, "duration": 3.161 }, { "text": "you don't just have to assume that that", "start": 1136.96, "duration": 3.48 }, { "text": "a name is always going to be at location", "start": 1138.72, "duration": 3.56 }, { "text": "zero house is always going to be at", "start": 1140.44, "duration": 3.359 }, { "text": "location one I mean that's the kind of", "start": 1142.28, "duration": 3.44 }, { "text": "thing especially if you had three four", "start": 1143.799, "duration": 4.441 }, { "text": "or more values eventually you or someone", "start": 1145.72, "duration": 4.4 }, { "text": "is going to get confused and forget what", "start": 1148.24, "duration": 3.72 }, { "text": "the order is and you're going to write", "start": 1150.12, "duration": 4.4 }, { "text": "buggy code so a dictionary is a little", "start": 1151.96, "duration": 3.8 }, { "text": "more powerful and that you can", "start": 1154.52, "duration": 3.639 }, { "text": "semantically associate Keys like little", "start": 1155.76, "duration": 5.159 }, { "text": "descriptions with the values those keys", "start": 1158.159, "duration": 4.841 }, { "text": "and those values respectively so let me", "start": 1160.919, "duration": 3.401 }, { "text": "go ahead and do this and we can do this", "start": 1163.0, "duration": 3.2 }, { "text": "in a few different ways but let me", "start": 1164.32, "duration": 3.719 }, { "text": "propose that we focus on get student", "start": 1166.2, "duration": 2.8 }, { "text": "here", "start": 1168.039, "duration": 3.161 }, { "text": "and let's go ahead and do this let me go", "start": 1169.0, "duration": 4.919 }, { "text": "ahead and uh in delete the", "start": 1171.2, "duration": 4.88 }, { "text": "implementation of get student Asis let", "start": 1173.919, "duration": 4.12 }, { "text": "me create a student variable and", "start": 1176.08, "duration": 4.04 }, { "text": "initialize it to an empty dictionary and", "start": 1178.039, "duration": 4.561 }, { "text": "I can do that with just two curly braces", "start": 1180.12, "duration": 4.32 }, { "text": "here and then let me go ahead and set", "start": 1182.6, "duration": 4.439 }, { "text": "two keys inside of that dictionary", "start": 1184.44, "duration": 3.88 }, { "text": "inside of the student there will be", "start": 1187.039, "duration": 3.841 }, { "text": "quote unquote a name key and the value", "start": 1188.32, "duration": 4.16 }, { "text": "of that is going to be whatever the", "start": 1190.88, "duration": 3.44 }, { "text": "return value of input is when I prompt", "start": 1192.48, "duration": 4.4 }, { "text": "the user for their name and then the", "start": 1194.32, "duration": 4.4 }, { "text": "house key inside of that that same", "start": 1196.88, "duration": 3.32 }, { "text": "student dictionary is going to be the", "start": 1198.72, "duration": 3.88 }, { "text": "return value of whatever the user types", "start": 1200.2, "duration": 4.64 }, { "text": "in for their house and lastly I'm going", "start": 1202.6, "duration": 5.52 }, { "text": "to go ahead and return student so now I", "start": 1204.84, "duration": 6.24 }, { "text": "am literally returning one thing still", "start": 1208.12, "duration": 5.439 }, { "text": "but this time it's a dict rather than a", "start": 1211.08, "duration": 4.479 }, { "text": "tupple rather than a list but there's", "start": 1213.559, "duration": 4.12 }, { "text": "still two things in it technically four", "start": 1215.559, "duration": 3.681 }, { "text": "things if you count the keys and the", "start": 1217.679, "duration": 4.721 }, { "text": "values but there's two key value pairs", "start": 1219.24, "duration": 4.559 }, { "text": "now my code up here is going to have to", "start": 1222.4, "duration": 3.04 }, { "text": "change a little bit and let's simplify", "start": 1223.799, "duration": 4.041 }, { "text": "this and remove for instance now the the", "start": 1225.44, "duration": 4.96 }, { "text": "pad if statement just to focus on what's", "start": 1227.84, "duration": 4.719 }, { "text": "changing at hand and let me go ahead now", "start": 1230.4, "duration": 3.96 }, { "text": "and leave line two alone I'm still going", "start": 1232.559, "duration": 4.24 }, { "text": "to have a student variable that gets", "start": 1234.36, "duration": 4.92 }, { "text": "assigned the return value of get student", "start": 1236.799, "duration": 4.561 }, { "text": "but what I want to do here now is", "start": 1239.28, "duration": 6.04 }, { "text": "actually access the keys inside of that", "start": 1241.36, "duration": 6.319 }, { "text": "dictionary not by numeric index which", "start": 1245.32, "duration": 4.88 }, { "text": "was for tuples and lists zero and one", "start": 1247.679, "duration": 5.801 }, { "text": "but by way of the keys now normally I", "start": 1250.2, "duration": 5.12 }, { "text": "might be in the habit as I personally am", "start": 1253.48, "duration": 3.76 }, { "text": "of using double quotes quote unquote", "start": 1255.32, "duration": 5.04 }, { "text": "name inside of there and quote unquote", "start": 1257.24, "duration": 5.84 }, { "text": "house inside of there but before I even", "start": 1260.36, "duration": 5.52 }, { "text": "run this code and show you a mistake see", "start": 1263.08, "duration": 4.8 }, { "text": "an error on the screen does anyone want", "start": 1265.88, "duration": 4.799 }, { "text": "to call out what I have done wrong here", "start": 1267.88, "duration": 5.32 }, { "text": "this is just an F string I just want to", "start": 1270.679, "duration": 5.081 }, { "text": "print out the value of the name key the", "start": 1273.2, "duration": 3.839 }, { "text": "value of the house key in this", "start": 1275.76, "duration": 3.799 }, { "text": "dictionary", "start": 1277.039, "duration": 2.52 }, { "text": "but you're your audio was a little", "start": 1280.6, "duration": 3.72 }, { "text": "garbled for us but I think I heard", "start": 1282.799, "duration": 3.401 }, { "text": "double quotes and single quotes so I'm", "start": 1284.32, "duration": 3.4 }, { "text": "going to assume that indeed you've", "start": 1286.2, "duration": 3.64 }, { "text": "identif precisely the issue I'm just", "start": 1287.72, "duration": 3.959 }, { "text": "going to confuse python right now even", "start": 1289.84, "duration": 3.88 }, { "text": "though this is an F string inside of", "start": 1291.679, "duration": 4.761 }, { "text": "Double quotes prefixed with an F I can't", "start": 1293.72, "duration": 4.8 }, { "text": "actually use my double quotes inside my", "start": 1296.44, "duration": 3.119 }, { "text": "double quotes because that's going to", "start": 1298.52, "duration": 2.759 }, { "text": "potentially confuse python indeed if I", "start": 1299.559, "duration": 4.161 }, { "text": "run this program now python of student.", "start": 1301.279, "duration": 5.041 }, { "text": "py and hit enter I get a syntax error so", "start": 1303.72, "duration": 4.439 }, { "text": "the program didn't even run fully it", "start": 1306.32, "duration": 3.28 }, { "text": "just couldn't be understood because it", "start": 1308.159, "duration": 4.041 }, { "text": "got confused by those double quotes So", "start": 1309.6, "duration": 4.36 }, { "text": "the simplest fix here would indeed just", "start": 1312.2, "duration": 4.32 }, { "text": "be to use not double quotes but single", "start": 1313.96, "duration": 5.599 }, { "text": "quotes around the keys or conversely", "start": 1316.52, "duration": 4.92 }, { "text": "flip the double quotes on the outside to", "start": 1319.559, "duration": 3.48 }, { "text": "single quotes then use double quotes on", "start": 1321.44, "duration": 2.96 }, { "text": "the inside you just want to be", "start": 1323.039, "duration": 3.601 }, { "text": "consistent so a subtle detail but again", "start": 1324.4, "duration": 3.96 }, { "text": "this is now specific to dictionary", "start": 1326.64, "duration": 4.639 }, { "text": "syntax this isn't fundamental to how", "start": 1328.36, "duration": 5.36 }, { "text": "we're solving this current problem at", "start": 1331.279, "duration": 4.161 }, { "text": "hand all right well let's go ahead and", "start": 1333.72, "duration": 3.199 }, { "text": "try this let me go ahead now and run", "start": 1335.44, "duration": 3.56 }, { "text": "python of student. let's go ahead and", "start": 1336.919, "duration": 3.88 }, { "text": "type in Harry let's type in Gryffindor", "start": 1339.0, "duration": 4.2 }, { "text": "and hopefully Harry is back from", "start": 1340.799, "duration": 4.88 }, { "text": "Gryffindor no syntax errors no other", "start": 1343.2, "duration": 4.88 }, { "text": "errors I think I'm back in business here", "start": 1345.679, "duration": 4.201 }, { "text": "and what I do like to be clear about", "start": 1348.08, "duration": 4.56 }, { "text": "using a dictionary is that it is", "start": 1349.88, "duration": 4.679 }, { "text": "allowing me just better semantics again", "start": 1352.64, "duration": 4.159 }, { "text": "I don't have to remember memorize", "start": 1354.559, "duration": 5.761 }, { "text": "document that zero is name one is house", "start": 1356.799, "duration": 6.681 }, { "text": "instead name is name and house is house", "start": 1360.32, "duration": 4.68 }, { "text": "it's just a little clear a little more", "start": 1363.48, "duration": 3.4 }, { "text": "expressive so that's generally a good", "start": 1365.0, "duration": 3.96 }, { "text": "thing especially if we stored more data", "start": 1366.88, "duration": 3.72 }, { "text": "about students than just their name in", "start": 1368.96, "duration": 4.12 }, { "text": "their house if you had three Fields four", "start": 1370.6, "duration": 4.559 }, { "text": "five 10 different fields no one's going", "start": 1373.08, "duration": 3.52 }, { "text": "to want to remember or be able to", "start": 1375.159, "duration": 3.88 }, { "text": "remember forever which is zero which is", "start": 1376.6, "duration": 4.8 }, { "text": "one which is two and so forth better to", "start": 1379.039, "duration": 5.041 }, { "text": "introduce uh names like name and house", "start": 1381.4, "duration": 4.519 }, { "text": "in this case but let me tighten this up", "start": 1384.08, "duration": 3.76 }, { "text": "further in indeed I'm typically in the", "start": 1385.919, "duration": 3.64 }, { "text": "habit of not introducing variables", "start": 1387.84, "duration": 3.56 }, { "text": "unnecessarily unless they make the code", "start": 1389.559, "duration": 4.48 }, { "text": "more readable and an alternative way to", "start": 1391.4, "duration": 4.6 }, { "text": "format the same code would be this", "start": 1394.039, "duration": 3.88 }, { "text": "strictly speaking I don't need to create", "start": 1396.0, "duration": 4.76 }, { "text": "an empty dictionary then add one key to", "start": 1397.919, "duration": 6.041 }, { "text": "it then add a second key to it and then", "start": 1400.76, "duration": 5.159 }, { "text": "return that dictionary I can actually", "start": 1403.96, "duration": 4.76 }, { "text": "consolidate this all into one statement", "start": 1405.919, "duration": 4.921 }, { "text": "if you will let me go ahead and do this", "start": 1408.72, "duration": 5.16 }, { "text": "let me go ahead and say name equals", "start": 1410.84, "duration": 6.719 }, { "text": "inputs return value house equals inputs", "start": 1413.88, "duration": 5.159 }, { "text": "return value and then instead of", "start": 1417.559, "duration": 3.161 }, { "text": "returning any variable name student", "start": 1419.039, "duration": 2.841 }, { "text": "which I'm going to propose doesn't need", "start": 1420.72, "duration": 3.76 }, { "text": "to exist anymore let me just create and", "start": 1421.88, "duration": 4.64 }, { "text": "return the dictionary all at once let me", "start": 1424.48, "duration": 4.72 }, { "text": "do quote unquote name in lowercase here", "start": 1426.52, "duration": 4.68 }, { "text": "and then the variable it's storing the", "start": 1429.2, "duration": 4.16 }, { "text": "user's name then quote unquote house as", "start": 1431.2, "duration": 4.04 }, { "text": "my second key the value of which is", "start": 1433.36, "duration": 4.08 }, { "text": "going to be house the variable now is", "start": 1435.24, "duration": 4.12 }, { "text": "this better maybe maybe not maybe the", "start": 1437.44, "duration": 3.599 }, { "text": "first way was a little more readable and", "start": 1439.36, "duration": 3.96 }, { "text": "that's totally fine to create variables", "start": 1441.039, "duration": 4.24 }, { "text": "if they improve the readability of your", "start": 1443.32, "duration": 4.239 }, { "text": "code but just know that you can also", "start": 1445.279, "duration": 4.121 }, { "text": "create and return a dictionary on the", "start": 1447.559, "duration": 3.72 }, { "text": "fly like this so to speak all in one", "start": 1449.4, "duration": 3.96 }, { "text": "line and I think it's arguably pretty", "start": 1451.279, "duration": 3.921 }, { "text": "reasonable in this case why it's just", "start": 1453.36, "duration": 3.76 }, { "text": "pretty short I probably wouldn't do this", "start": 1455.2, "duration": 3.76 }, { "text": "if it got longer and longer and longer I", "start": 1457.12, "duration": 3.559 }, { "text": "might minimally then start moving my key", "start": 1458.96, "duration": 4.16 }, { "text": "value pairs to separate lines but this", "start": 1460.679, "duration": 4.681 }, { "text": "would just be a slightly more compact", "start": 1463.12, "duration": 4.76 }, { "text": "way of doing this as well but let me", "start": 1465.36, "duration": 4.16 }, { "text": "propose we do one more change let's go", "start": 1467.88, "duration": 3.84 }, { "text": "ahead and introduce that same special", "start": 1469.52, "duration": 4.68 }, { "text": "casing of Padma to fix her house from", "start": 1471.72, "duration": 4.8 }, { "text": "Gryffindor for instance to Raven claw", "start": 1474.2, "duration": 4.44 }, { "text": "how do we do this with dictionaries well", "start": 1476.52, "duration": 5.279 }, { "text": "dictionaries like lists are mutable you", "start": 1478.64, "duration": 5.8 }, { "text": "can change what is in them just like you", "start": 1481.799, "duration": 4.6 }, { "text": "can lists and how do you do that is just", "start": 1484.44, "duration": 3.64 }, { "text": "a little different syntactically so", "start": 1486.399, "duration": 4.041 }, { "text": "let's go back into Main and do this fix", "start": 1488.08, "duration": 6.4 }, { "text": "if the student variable has a name key", "start": 1490.44, "duration": 8.119 }, { "text": "that equals equals Padma then indented", "start": 1494.48, "duration": 7.16 }, { "text": "go ahead and change the value of the", "start": 1498.559, "duration": 5.761 }, { "text": "house key inside of that student", "start": 1501.64, "duration": 6.039 }, { "text": "dictionary to be quote unquote Ravenclaw", "start": 1504.32, "duration": 5.959 }, { "text": "instead so very similar in spirit to", "start": 1507.679, "duration": 4.321 }, { "text": "what we did with a list but instead of", "start": 1510.279, "duration": 4.081 }, { "text": "using location zero and one we're much", "start": 1512.0, "duration": 4.799 }, { "text": "more clearly explicitly semantically", "start": 1514.36, "duration": 4.52 }, { "text": "using quote unquote name and quote", "start": 1516.799, "duration": 4.36 }, { "text": "unquote house because you index into", "start": 1518.88, "duration": 4.72 }, { "text": "lists and topples using numbers but you", "start": 1521.159, "duration": 5.721 }, { "text": "index into dictionaries using strings as", "start": 1523.6, "duration": 5.04 }, { "text": "I've done here all right let me go ahead", "start": 1526.88, "duration": 4.76 }, { "text": "and run python of studenty we'll again", "start": 1528.64, "duration": 5.68 }, { "text": "do Harry from Gryffindor and I think all", "start": 1531.64, "duration": 4.88 }, { "text": "as well let me run it one more time this", "start": 1534.32, "duration": 4.359 }, { "text": "time with Padma who in the movies is", "start": 1536.52, "duration": 4.72 }, { "text": "from Gryffindor but should really be", "start": 1538.679, "duration": 3.281 }, { "text": "from", "start": 1541.24, "duration": 3.84 }, { "text": "Ravenclaw are any questions then on this", "start": 1541.96, "duration": 6.4 }, { "text": "progression from tuples to lists to", "start": 1545.08, "duration": 5.04 }, { "text": "dictionaries we haven't necessarily", "start": 1548.36, "duration": 4.24 }, { "text": "introduced anything new other than those", "start": 1550.12, "duration": 5.159 }, { "text": "tuples which have been available to us", "start": 1552.6, "duration": 4.76 }, { "text": "all this time but the goal at the moment", "start": 1555.279, "duration": 3.921 }, { "text": "is just just to demonstrate this", "start": 1557.36, "duration": 3.52 }, { "text": "distinction among these different data", "start": 1559.2, "duration": 3.719 }, { "text": "types and how they each work a little", "start": 1560.88, "duration": 5.12 }, { "text": "bit differently what if a a combination", "start": 1562.919, "duration": 6.401 }, { "text": "of lists is there in a tuple so is the", "start": 1566.0, "duration": 6.399 }, { "text": "list like we can change the list because", "start": 1569.32, "duration": 6.4 }, { "text": "tupple are immutable but lists are", "start": 1572.399, "duration": 5.601 }, { "text": "mutable correct you can change the", "start": 1575.72, "duration": 4.079 }, { "text": "contents of lists and you can put most", "start": 1578.0, "duration": 3.919 }, { "text": "anything you want in them other lists or", "start": 1579.799, "duration": 3.88 }, { "text": "strings as I've done integers or", "start": 1581.919, "duration": 3.841 }, { "text": "anything else tles you can do the exact", "start": 1583.679, "duration": 4.0 }, { "text": "same thing but you cannot change them", "start": 1585.76, "duration": 4.6 }, { "text": "once you've created them a dictionary is", "start": 1587.679, "duration": 5.321 }, { "text": "more like a list in that it is mutable", "start": 1590.36, "duration": 5.88 }, { "text": "you can change it but the way you index", "start": 1593.0, "duration": 5.24 }, { "text": "into a dictionary is by way of these", "start": 1596.24, "duration": 4.52 }, { "text": "Keys these strings as we keep seeing", "start": 1598.24, "duration": 5.88 }, { "text": "rather than by numbers those numeric", "start": 1600.76, "duration": 6.159 }, { "text": "indices all right well let me propose", "start": 1604.12, "duration": 5.36 }, { "text": "that there is yet another way of solving", "start": 1606.919, "duration": 5.0 }, { "text": "this problem and indeed I would argue", "start": 1609.48, "duration": 4.439 }, { "text": "that there's now an opportunity to hand", "start": 1611.919, "duration": 3.36 }, { "text": "even though this program isn't", "start": 1613.919, "duration": 3.36 }, { "text": "particularly complicated all I'm doing", "start": 1615.279, "duration": 5.321 }, { "text": "is collecting a name from the user and a", "start": 1617.279, "duration": 5.361 }, { "text": "uh house from the user you could imagine", "start": 1620.6, "duration": 4.0 }, { "text": "wanting longer term to collect even more", "start": 1622.64, "duration": 4.039 }, { "text": "information like the student's Patronis", "start": 1624.6, "duration": 3.84 }, { "text": "or magical spell or a whole bunch of", "start": 1626.679, "duration": 3.36 }, { "text": "other information that might belong in a", "start": 1628.44, "duration": 3.959 }, { "text": "student and right now we're just kind of", "start": 1630.039, "duration": 5.24 }, { "text": "using these very general purpose data", "start": 1632.399, "duration": 5.321 }, { "text": "types in Python a tuple to combine some", "start": 1635.279, "duration": 4.601 }, { "text": "values together a list to do the same", "start": 1637.72, "duration": 4.64 }, { "text": "but let us change it later a dictionary", "start": 1639.88, "duration": 4.159 }, { "text": "which is more powerful because it's a", "start": 1642.36, "duration": 3.88 }, { "text": "little more structured it does have keys", "start": 1644.039, "duration": 4.88 }, { "text": "and it has values not just values but", "start": 1646.24, "duration": 4.48 }, { "text": "you know what this we wouldn't have to", "start": 1648.919, "duration": 3.441 }, { "text": "be having this conversation if the", "start": 1650.72, "duration": 4.04 }, { "text": "authors of python had just given us a", "start": 1652.36, "duration": 5.0 }, { "text": "data type called student right wouldn't", "start": 1654.76, "duration": 4.32 }, { "text": "it have been nice if there were just a", "start": 1657.36, "duration": 3.52 }, { "text": "type of variable I could create in my", "start": 1659.08, "duration": 3.92 }, { "text": "code called student then we wouldn't", "start": 1660.88, "duration": 3.399 }, { "text": "have to figure out well do we use a", "start": 1663.0, "duration": 3.919 }, { "text": "tuple or a list or a dictionary but", "start": 1664.279, "duration": 4.361 }, { "text": "that's pretty reasonable right you could", "start": 1666.919, "duration": 4.161 }, { "text": "imagine just a how slippery of a slope", "start": 1668.64, "duration": 5.159 }, { "text": "that is so to speak if the creators of a", "start": 1671.08, "duration": 4.68 }, { "text": "language had to anticipate all the", "start": 1673.799, "duration": 3.681 }, { "text": "possible types of data that Pro", "start": 1675.76, "duration": 2.919 }, { "text": "programmers like you and me want to", "start": 1677.48, "duration": 3.679 }, { "text": "store in your programs so they just gave", "start": 1678.679, "duration": 4.561 }, { "text": "us these general purpose tools but they", "start": 1681.159, "duration": 4.481 }, { "text": "gave us another general purpose tool", "start": 1683.24, "duration": 4.439 }, { "text": "that's going to allow us to create our", "start": 1685.64, "duration": 4.519 }, { "text": "own data types as well and actually give", "start": 1687.679, "duration": 5.681 }, { "text": "them names and that uh terminology is a", "start": 1690.159, "duration": 6.041 }, { "text": "class A Class is kind of like a", "start": 1693.36, "duration": 6.0 }, { "text": "blueprint for pieces of data object so", "start": 1696.2, "duration": 5.8 }, { "text": "to speak a class is kind of like a mold", "start": 1699.36, "duration": 4.919 }, { "text": "that you can define and give a name and", "start": 1702.0, "duration": 4.12 }, { "text": "when you use that mold or you use that", "start": 1704.279, "duration": 4.76 }, { "text": "blueprint you get types of data that are", "start": 1706.12, "duration": 5.679 }, { "text": "designed exactly as you want so in short", "start": 1709.039, "duration": 5.36 }, { "text": "classes allow you to invent your own", "start": 1711.799, "duration": 5.12 }, { "text": "data types in Python and give them a", "start": 1714.399, "duration": 5.28 }, { "text": "name and this is a primary feature uh of", "start": 1716.919, "duration": 5.081 }, { "text": "object-oriented programming to be able", "start": 1719.679, "duration": 4.24 }, { "text": "to create your own objects in this way", "start": 1722.0, "duration": 4.039 }, { "text": "and in the case of python and classes", "start": 1723.919, "duration": 4.801 }, { "text": "even give them some custom names so what", "start": 1726.039, "duration": 4.601 }, { "text": "does this mean in real terms well let me", "start": 1728.72, "duration": 4.439 }, { "text": "go ahead and come back to VSS code here", "start": 1730.64, "duration": 4.24 }, { "text": "and let me propose that we introduce a", "start": 1733.159, "duration": 3.721 }, { "text": "little bit of new syntax I'm going to go", "start": 1734.88, "duration": 4.0 }, { "text": "ahead and clear my terminal window first", "start": 1736.88, "duration": 4.08 }, { "text": "I'm going to go to the top of my file", "start": 1738.88, "duration": 3.799 }, { "text": "and I'm just going to start a thought", "start": 1740.96, "duration": 3.559 }, { "text": "but not finish it yet I'm going to use", "start": 1742.679, "duration": 4.921 }, { "text": "this new keyword for classes called", "start": 1744.519, "duration": 5.52 }, { "text": "literally class so indeed the new", "start": 1747.6, "duration": 4.199 }, { "text": "keyword we're going to have here and if", "start": 1750.039, "duration": 3.921 }, { "text": "I go back to our slides here this would", "start": 1751.799, "duration": 3.681 }, { "text": "be the official URL where you can read", "start": 1753.96, "duration": 3.319 }, { "text": "up more on this particular feature of", "start": 1755.48, "duration": 4.799 }, { "text": "python in the official tutorial class is", "start": 1757.279, "duration": 5.441 }, { "text": "a new keyword we can use now this is", "start": 1760.279, "duration": 4.321 }, { "text": "coincidentally related to students", "start": 1762.72, "duration": 3.439 }, { "text": "because students take classes but it has", "start": 1764.6, "duration": 3.16 }, { "text": "nothing to do with the fact that dealing", "start": 1766.159, "duration": 3.88 }, { "text": "with students class is a general purpose", "start": 1767.76, "duration": 4.56 }, { "text": "term in a lot of languages python among", "start": 1770.039, "duration": 4.281 }, { "text": "them that allow you to Define these", "start": 1772.32, "duration": 5.16 }, { "text": "custom containers with custom names for", "start": 1774.32, "duration": 5.28 }, { "text": "pieces of data so let's go back to vs", "start": 1777.48, "duration": 4.12 }, { "text": "code let's use this new keyword and let", "start": 1779.6, "duration": 4.24 }, { "text": "me propose that we create a class called", "start": 1781.6, "duration": 3.959 }, { "text": "student and by convention I'm going to", "start": 1783.84, "duration": 3.839 }, { "text": "use a capital S here and I'm going to go", "start": 1785.559, "duration": 5.441 }, { "text": "ahead and with a colon get to later the", "start": 1787.679, "duration": 4.921 }, { "text": "implementation of this class so I'm just", "start": 1791.0, "duration": 3.159 }, { "text": "going to use dot dot dot which is a", "start": 1792.6, "duration": 3.439 }, { "text": "valid placeholder for now that just", "start": 1794.159, "duration": 2.961 }, { "text": "indicates to me that I'm going to come", "start": 1796.039, "duration": 3.24 }, { "text": "back back to implementing this later but", "start": 1797.12, "duration": 5.559 }, { "text": "as of now it does in fact exist I now", "start": 1799.279, "duration": 6.601 }, { "text": "have a student uh class defined for me", "start": 1802.679, "duration": 6.081 }, { "text": "that I can now use in my code here how", "start": 1805.88, "duration": 5.44 }, { "text": "am I going to use it well first of all", "start": 1808.76, "duration": 5.039 }, { "text": "let me go down to get student and let me", "start": 1811.32, "duration": 4.599 }, { "text": "change this code to no longer use a", "start": 1813.799, "duration": 4.88 }, { "text": "dictionary but to use this class I'm", "start": 1815.919, "duration": 4.161 }, { "text": "going to do this I'm going to give", "start": 1818.679, "duration": 3.281 }, { "text": "myself a variable called student as I've", "start": 1820.08, "duration": 3.68 }, { "text": "done before but I'm going to set it", "start": 1821.96, "duration": 4.599 }, { "text": "equal to Capital student open", "start": 1823.76, "duration": 5.48 }, { "text": "parenthesis close parenthesis so I'm", "start": 1826.559, "duration": 4.921 }, { "text": "going to do what appears to be calling a", "start": 1829.24, "duration": 4.76 }, { "text": "function and that function student with", "start": 1831.48, "duration": 5.4 }, { "text": "a capital S notice matches the name that", "start": 1834.0, "duration": 5.519 }, { "text": "I gave this class at the top of my file", "start": 1836.88, "duration": 4.399 }, { "text": "all right what do I next want to do I'm", "start": 1839.519, "duration": 3.0 }, { "text": "going to go ahead and give this student", "start": 1841.279, "duration": 3.601 }, { "text": "a name now if I were still using a", "start": 1842.519, "duration": 5.201 }, { "text": "dictionary I would say student quote", "start": 1844.88, "duration": 5.76 }, { "text": "unquote name using square brackets but", "start": 1847.72, "duration": 5.319 }, { "text": "this is not a dictionary it turns out", "start": 1850.64, "duration": 4.279 }, { "text": "classes have what for now we'll call", "start": 1853.039, "duration": 3.841 }, { "text": "attributes properties of sorts that", "start": 1854.919, "duration": 4.24 }, { "text": "allow you to specify values inside of", "start": 1856.88, "duration": 4.08 }, { "text": "them and the Syntax for that happens to", "start": 1859.159, "duration": 4.081 }, { "text": "be a DOT we've seen dots before we've", "start": 1860.96, "duration": 4.12 }, { "text": "used it in the context of modules and", "start": 1863.24, "duration": 3.919 }, { "text": "libraries more generally this is another", "start": 1865.08, "duration": 3.959 }, { "text": "similar in spirit use of a DOT that", "start": 1867.159, "duration": 4.041 }, { "text": "allows you to get at something inside of", "start": 1869.039, "duration": 5.24 }, { "text": "something else so student. name is going", "start": 1871.2, "duration": 5.359 }, { "text": "to be the syntax I use for giving this", "start": 1874.279, "duration": 4.681 }, { "text": "student a name and that name is going to", "start": 1876.559, "duration": 5.321 }, { "text": "be whatever the return value of name is", "start": 1878.96, "duration": 4.36 }, { "text": "and then I'm going to go ahead and say", "start": 1881.88, "duration": 3.88 }, { "text": "student.h house to give another", "start": 1883.32, "duration": 4.76 }, { "text": "attribute called house and give that the", "start": 1885.76, "duration": 4.2 }, { "text": "return value of input here prompting the", "start": 1888.08, "duration": 3.839 }, { "text": "user for house and then as before I'm", "start": 1889.96, "duration": 4.599 }, { "text": "just going to return student but now", "start": 1891.919, "duration": 5.48 }, { "text": "what's really powerful about class and", "start": 1894.559, "duration": 4.401 }, { "text": "object-oriented programming more", "start": 1897.399, "duration": 3.88 }, { "text": "generally is that I've created this", "start": 1898.96, "duration": 4.36 }, { "text": "custom data type called literally", "start": 1901.279, "duration": 4.88 }, { "text": "student capital S I've stored one such", "start": 1903.32, "duration": 4.8 }, { "text": "student in a variable like I can always", "start": 1906.159, "duration": 3.721 }, { "text": "do in a variable called student", "start": 1908.12, "duration": 3.64 }, { "text": "lowercase s but I could call it anything", "start": 1909.88, "duration": 3.48 }, { "text": "I want I just make sense to call it", "start": 1911.76, "duration": 3.68 }, { "text": "student as well but lowercase for", "start": 1913.36, "duration": 4.199 }, { "text": "clarity and then I'm returning that", "start": 1915.44, "duration": 4.239 }, { "text": "variable and because of my syntax in", "start": 1917.559, "duration": 5.281 }, { "text": "lines 14 and 15 that has the result of", "start": 1919.679, "duration": 6.88 }, { "text": "putting inside of that class a name", "start": 1922.84, "duration": 6.719 }, { "text": "attribute and a house attribute I just", "start": 1926.559, "duration": 5.08 }, { "text": "need to make one more change up here I'm", "start": 1929.559, "duration": 3.801 }, { "text": "going to go ahead and remove our Padma", "start": 1931.639, "duration": 3.481 }, { "text": "code just so we can focus only on what's", "start": 1933.36, "duration": 4.279 }, { "text": "new rather than fixing her house and I'm", "start": 1935.12, "duration": 4.08 }, { "text": "going to go in here and change the", "start": 1937.639, "duration": 3.441 }, { "text": "syntax that previously was for", "start": 1939.2, "duration": 4.68 }, { "text": "dictionaries again dictionaries use", "start": 1941.08, "duration": 5.28 }, { "text": "square brackets and then strings in", "start": 1943.88, "duration": 4.399 }, { "text": "quotes either single quotes or double", "start": 1946.36, "duration": 4.039 }, { "text": "quotes depending on the context here", "start": 1948.279, "duration": 3.36 }, { "text": "though I'm going to change this to be", "start": 1950.399, "duration": 4.28 }, { "text": "student. name and over here I'm going to", "start": 1951.639, "duration": 6.121 }, { "text": "change it to be student. housee and", "start": 1954.679, "duration": 4.521 }, { "text": "that's just going to be my new syntax", "start": 1957.76, "duration": 3.159 }, { "text": "for getting the contents of what appears", "start": 1959.2, "duration": 4.52 }, { "text": "to be a class called student let me go", "start": 1960.919, "duration": 5.841 }, { "text": "ahead and rerun python of student. by", "start": 1963.72, "duration": 5.0 }, { "text": "enter let's type in Harry's name as", "start": 1966.76, "duration": 3.68 }, { "text": "before let's put him in Gryffindor", "start": 1968.72, "duration": 4.079 }, { "text": "crossing our fingers as we often do and", "start": 1970.44, "duration": 5.199 }, { "text": "Harry is indeed from", "start": 1972.799, "duration": 5.321 }, { "text": "Gryffindor what the though have I done", "start": 1975.639, "duration": 4.04 }, { "text": "let's introduce one other bit of", "start": 1978.12, "duration": 4.799 }, { "text": "terminology here it turns out that I can", "start": 1979.679, "duration": 5.96 }, { "text": "create a class using that class keyword", "start": 1982.919, "duration": 5.041 }, { "text": "but anytime you use a class you're", "start": 1985.639, "duration": 4.441 }, { "text": "creating what are called objects and", "start": 1987.96, "duration": 3.92 }, { "text": "here is the word objects as an", "start": 1990.08, "duration": 4.8 }, { "text": "objectoriented programming or oop let me", "start": 1991.88, "duration": 4.759 }, { "text": "go back to my code here and even though", "start": 1994.88, "duration": 3.44 }, { "text": "I haven't really implemented much of it", "start": 1996.639, "duration": 3.481 }, { "text": "at all I literally just left it with a", "start": 1998.32, "duration": 4.239 }, { "text": "dot dot dot that's enough code lines one", "start": 2000.12, "duration": 4.88 }, { "text": "and two to just invent a new data type", "start": 2002.559, "duration": 5.041 }, { "text": "called student capital s that may or may", "start": 2005.0, "duration": 4.279 }, { "text": "not have some future functionality as", "start": 2007.6, "duration": 3.959 }, { "text": "well that's enough to create a class", "start": 2009.279, "duration": 5.081 }, { "text": "what though am I doing on line 11 on", "start": 2011.559, "duration": 5.561 }, { "text": "line 11 what I'm technically doing is", "start": 2014.36, "duration": 6.0 }, { "text": "creating an object of that class so this", "start": 2017.12, "duration": 5.64 }, { "text": "too is another term of art you create", "start": 2020.36, "duration": 5.24 }, { "text": "objects from classes so if we go back to", "start": 2022.76, "duration": 4.399 }, { "text": "that metaphor that a class is like a", "start": 2025.6, "duration": 4.16 }, { "text": "blueprint for a house or a class is like", "start": 2027.159, "duration": 5.64 }, { "text": "a mold an object is when you use that", "start": 2029.76, "duration": 5.399 }, { "text": "blueprint to build a specific house or", "start": 2032.799, "duration": 4.201 }, { "text": "something that comes out of in plaster", "start": 2035.159, "duration": 3.961 }, { "text": "the mold when you actually use that mold", "start": 2037.0, "duration": 5.32 }, { "text": "to create such an object so a class is", "start": 2039.12, "duration": 5.799 }, { "text": "again the definition of a new data type", "start": 2042.32, "duration": 5.52 }, { "text": "the object is the Incarnation of or", "start": 2044.919, "duration": 5.68 }, { "text": "technically instantiation of and another", "start": 2047.84, "duration": 4.999 }, { "text": "term for objects would actually be an", "start": 2050.599, "duration": 4.921 }, { "text": "instance you have instances of classes", "start": 2052.839, "duration": 4.481 }, { "text": "as well so that's a lot of vocabulary", "start": 2055.52, "duration": 3.159 }, { "text": "but at the end of the day it just boils", "start": 2057.32, "duration": 3.2 }, { "text": "down to this you can Define your own", "start": 2058.679, "duration": 3.96 }, { "text": "class which is really your own data type", "start": 2060.52, "duration": 4.24 }, { "text": "you can then store attributes inside of", "start": 2062.639, "duration": 4.361 }, { "text": "it using this dot notation here and and", "start": 2064.76, "duration": 3.56 }, { "text": "then you can access those same", "start": 2067.0, "duration": 4.28 }, { "text": "attributes using Code like this here and", "start": 2068.32, "duration": 5.72 }, { "text": "now I have a proper student data type", "start": 2071.28, "duration": 4.52 }, { "text": "and I don't have to kind of hack", "start": 2074.04, "duration": 3.52 }, { "text": "something together using a tuple or a", "start": 2075.8, "duration": 4.039 }, { "text": "list or even a dictionary I now have a", "start": 2077.56, "duration": 4.88 }, { "text": "proper data type called student that the", "start": 2079.839, "duration": 5.28 }, { "text": "authors of python didn't give me I gave", "start": 2082.44, "duration": 6.679 }, { "text": "myself any questions now on classes this", "start": 2085.119, "duration": 6.081 }, { "text": "new keyword class or this idea of these", "start": 2089.119, "duration": 5.28 }, { "text": "objects or instances thereof is the", "start": 2091.2, "duration": 8.0 }, { "text": "class object mut or immutable a good", "start": 2094.399, "duration": 6.321 }, { "text": "question and we've clearly laid the", "start": 2099.2, "duration": 3.12 }, { "text": "stage for having that conversation about", "start": 2100.72, "duration": 3.639 }, { "text": "every data type now we will see that", "start": 2102.32, "duration": 4.759 }, { "text": "they are mutable but you can make them", "start": 2104.359, "duration": 4.921 }, { "text": "immutable so you can get the best of", "start": 2107.079, "duration": 4.52 }, { "text": "both worlds Now by writing some actual", "start": 2109.28, "duration": 3.88 }, { "text": "code and we'll write more code than the", "start": 2111.599, "duration": 3.601 }, { "text": "dot dot dot in just a bit other", "start": 2113.16, "duration": 4.28 }, { "text": "questions on classes or these objects", "start": 2115.2, "duration": 4.2 }, { "text": "thereof then what would be the", "start": 2117.44, "duration": 4.679 }, { "text": "properties of those glasses uh so at the", "start": 2119.4, "duration": 4.52 }, { "text": "moment the properties of or the", "start": 2122.119, "duration": 3.48 }, { "text": "attributes of as I've been calling them", "start": 2123.92, "duration": 4.56 }, { "text": "thus far would just be name and house it", "start": 2125.599, "duration": 4.361 }, { "text": "turns out that there may very well be", "start": 2128.48, "duration": 3.879 }, { "text": "other attributes built into classes that", "start": 2129.96, "duration": 4.44 }, { "text": "we may see before long but for now the", "start": 2132.359, "duration": 3.681 }, { "text": "only two attributes that I care about", "start": 2134.4, "duration": 4.04 }, { "text": "are the ones that I myself created", "start": 2136.04, "duration": 5.2 }, { "text": "namely name and house are again what I", "start": 2138.44, "duration": 4.639 }, { "text": "would call attributes and in a little", "start": 2141.24, "duration": 3.08 }, { "text": "bit we're going to start calling those", "start": 2143.079, "duration": 3.04 }, { "text": "same attributes more technically", "start": 2144.32, "duration": 4.56 }, { "text": "instance variables name and house as", "start": 2146.119, "duration": 4.841 }, { "text": "I've presented them here in vs code are", "start": 2148.88, "duration": 4.88 }, { "text": "really just variables called name and", "start": 2150.96, "duration": 6.359 }, { "text": "called house inside of an object object", "start": 2153.76, "duration": 7.12 }, { "text": "whose type is student all right so what", "start": 2157.319, "duration": 5.561 }, { "text": "more can we do with these classes well", "start": 2160.88, "duration": 4.32 }, { "text": "again online 11 is where we're", "start": 2162.88, "duration": 5.239 }, { "text": "instantiating an object of the student", "start": 2165.2, "duration": 5.159 }, { "text": "class and assigning it to a student", "start": 2168.119, "duration": 4.281 }, { "text": "variable we're then adding attributes", "start": 2170.359, "duration": 4.321 }, { "text": "name and house respectively on lines 12", "start": 2172.4, "duration": 4.36 }, { "text": "and 13 currently both of those have", "start": 2174.68, "duration": 3.96 }, { "text": "values that are technically strings or", "start": 2176.76, "duration": 3.4 }, { "text": "stirs because that's what the return", "start": 2178.64, "duration": 3.52 }, { "text": "value of input is but those attributes", "start": 2180.16, "duration": 3.72 }, { "text": "values could actually be any data type", "start": 2182.16, "duration": 3.199 }, { "text": "we're just keeping things simple and", "start": 2183.88, "duration": 3.32 }, { "text": "focusing on defining students in terms", "start": 2185.359, "duration": 4.361 }, { "text": "of two strings name and house and then", "start": 2187.2, "duration": 5.0 }, { "text": "on line 14 we're returning that variable", "start": 2189.72, "duration": 4.8 }, { "text": "we're returning that object to main so", "start": 2192.2, "duration": 4.32 }, { "text": "that we can actually print out who is", "start": 2194.52, "duration": 3.839 }, { "text": "from what house well let's go ahead and", "start": 2196.52, "duration": 3.559 }, { "text": "add a bit more functionality here", "start": 2198.359, "duration": 4.041 }, { "text": "because right now on lines 12 and 13", "start": 2200.079, "duration": 4.881 }, { "text": "this is a little manual and it's a", "start": 2202.4, "duration": 4.4 }, { "text": "little reckless of me to just be putting", "start": 2204.96, "duration": 4.639 }, { "text": "anything I want inside of this student", "start": 2206.8, "duration": 5.2 }, { "text": "object it turns out with classes unlike", "start": 2209.599, "duration": 4.121 }, { "text": "with dictionaries we can actually", "start": 2212.0, "duration": 3.92 }, { "text": "standardize all the more what those", "start": 2213.72, "duration": 5.04 }, { "text": "attributes can be and how what kinds of", "start": 2215.92, "duration": 5.04 }, { "text": "values you can set them to so let me go", "start": 2218.76, "duration": 4.52 }, { "text": "ahead and do this let me propose that it", "start": 2220.96, "duration": 5.0 }, { "text": "would actually be really nice if instead", "start": 2223.28, "duration": 5.68 }, { "text": "of doing this here let me go ahead and", "start": 2225.96, "duration": 5.08 }, { "text": "simplify my code as follows let me go", "start": 2228.96, "duration": 4.08 }, { "text": "ahead and give myself a local variable", "start": 2231.04, "duration": 3.52 }, { "text": "called name and set it equal to the", "start": 2233.04, "duration": 3.319 }, { "text": "return value of input like we've done", "start": 2234.56, "duration": 3.6 }, { "text": "many times now already let me give", "start": 2236.359, "duration": 3.561 }, { "text": "myself one other variable for now called", "start": 2238.16, "duration": 3.48 }, { "text": "house and set it equal to the return", "start": 2239.92, "duration": 4.12 }, { "text": "value of input as well prompting the", "start": 2241.64, "duration": 5.24 }, { "text": "user for their house and now and instead", "start": 2244.04, "duration": 5.16 }, { "text": "of creating a student object from my", "start": 2246.88, "duration": 5.479 }, { "text": "student class and then manually putting", "start": 2249.2, "duration": 5.72 }, { "text": "the name attribute inside of it and the", "start": 2252.359, "duration": 4.881 }, { "text": "house attribute inside of it let me", "start": 2254.92, "duration": 4.56 }, { "text": "actually do something more powerful let", "start": 2257.24, "duration": 5.119 }, { "text": "me do this let me call that student", "start": 2259.48, "duration": 5.44 }, { "text": "function which is identical to the class", "start": 2262.359, "duration": 5.081 }, { "text": "name just by defining a class you get a", "start": 2264.92, "duration": 5.08 }, { "text": "function whose name is identical to the", "start": 2267.44, "duration": 4.32 }, { "text": "class name with the capital letter", "start": 2270.0, "duration": 3.96 }, { "text": "included but instead of just doing open", "start": 2271.76, "duration": 4.44 }, { "text": "parenthesis close parenthesis let me", "start": 2273.96, "duration": 4.92 }, { "text": "pass in the name that I want to fill", "start": 2276.2, "duration": 5.32 }, { "text": "this this object with and the house that", "start": 2278.88, "duration": 4.68 }, { "text": "I want to put in that object as well and", "start": 2281.52, "duration": 3.68 }, { "text": "now let me set the return value as", "start": 2283.56, "duration": 5.96 }, { "text": "before to be student equals like this so", "start": 2285.2, "duration": 6.04 }, { "text": "what have I done that's different", "start": 2289.52, "duration": 3.079 }, { "text": "fundamentally I'm still getting user", "start": 2291.24, "duration": 3.24 }, { "text": "input in the same way I'm using input on", "start": 2292.599, "duration": 4.361 }, { "text": "line 11 and input on line 12 and I just", "start": 2294.48, "duration": 3.92 }, { "text": "so happen to be storing those return", "start": 2296.96, "duration": 4.28 }, { "text": "values in local variables but now now", "start": 2298.4, "duration": 4.24 }, { "text": "we're setting the stage for the more", "start": 2301.24, "duration": 3.879 }, { "text": "powerful features of classes and", "start": 2302.64, "duration": 3.959 }, { "text": "objectoriented programming more", "start": 2305.119, "duration": 3.441 }, { "text": "generally notice that I'm deliberately", "start": 2306.599, "duration": 4.881 }, { "text": "passing to this capital S student", "start": 2308.56, "duration": 6.16 }, { "text": "function name comma house I'm passing in", "start": 2311.48, "duration": 5.76 }, { "text": "arguments to the function now the", "start": 2314.72, "duration": 3.72 }, { "text": "student class is not going to know what", "start": 2317.24, "duration": 3.879 }, { "text": "to do with those yet but now I'm sort of", "start": 2318.44, "duration": 5.28 }, { "text": "standardizing how I'm passing data into", "start": 2321.119, "duration": 4.441 }, { "text": "this student class and ultimately it's", "start": 2323.72, "duration": 4.04 }, { "text": "going to give me an opportunity to error", "start": 2325.56, "duration": 3.84 }, { "text": "check those inputs to make sure that the", "start": 2327.76, "duration": 3.44 }, { "text": "name is valid that it has a value and", "start": 2329.4, "duration": 3.52 }, { "text": "it's not just the user hitting enter", "start": 2331.2, "duration": 3.32 }, { "text": "it's going to allow me to ensure that", "start": 2332.92, "duration": 3.64 }, { "text": "it's a valid house that it's griffindor", "start": 2334.52, "duration": 4.0 }, { "text": "door or Hufflepuff or Ravenclaw or", "start": 2336.56, "duration": 4.039 }, { "text": "Slytherin or not just hitting enter or", "start": 2338.52, "duration": 4.559 }, { "text": "some random value that the user types in", "start": 2340.599, "duration": 4.361 }, { "text": "because I'm passing name and house to", "start": 2343.079, "duration": 4.801 }, { "text": "the student class this particular", "start": 2344.96, "duration": 4.68 }, { "text": "function I'm going to have more control", "start": 2347.88, "duration": 3.92 }, { "text": "over the correctness of my data so let's", "start": 2349.64, "duration": 4.36 }, { "text": "now go up to the student class which up", "start": 2351.8, "duration": 4.64 }, { "text": "until now I left as just dot dot dot it", "start": 2354.0, "duration": 5.64 }, { "text": "turns out that in the context of classes", "start": 2356.44, "duration": 6.0 }, { "text": "there are a number of not just uh", "start": 2359.64, "duration": 4.719 }, { "text": "attributes or instance variables that", "start": 2362.44, "duration": 4.84 }, { "text": "you can put inside but also method Me", "start": 2364.359, "duration": 6.161 }, { "text": "classes come with certain methods or", "start": 2367.28, "duration": 5.559 }, { "text": "functions inside of them that you can", "start": 2370.52, "duration": 4.76 }, { "text": "Define and they just behave in a special", "start": 2372.839, "duration": 5.361 }, { "text": "way by nature of how python works these", "start": 2375.28, "duration": 5.4 }, { "text": "functions allow you to determine", "start": 2378.2, "duration": 4.56 }, { "text": "behavior in a standard way they are", "start": 2380.68, "duration": 4.56 }, { "text": "indeed special methods in that sense now", "start": 2382.76, "duration": 3.839 }, { "text": "what do I mean by this well let me go", "start": 2385.24, "duration": 4.16 }, { "text": "back to VSS code here and let me propose", "start": 2386.599, "duration": 5.76 }, { "text": "that I start to define a standard", "start": 2389.4, "duration": 6.08 }, { "text": "function called uh underscore underscore", "start": 2392.359, "duration": 5.921 }, { "text": "or Dunder as it's abbreviated in it", "start": 2395.48, "duration": 5.08 }, { "text": "underscore underscore and then I'm going", "start": 2398.28, "duration": 5.6 }, { "text": "to go ahead and do open parenthesis and", "start": 2400.56, "duration": 5.32 }, { "text": "then I'm going to put in here literally", "start": 2403.88, "duration": 3.84 }, { "text": "the word self more on that in just a", "start": 2405.88, "duration": 4.32 }, { "text": "moment but now inside of this function", "start": 2407.72, "duration": 5.119 }, { "text": "I'm going to have an opportunity to", "start": 2410.2, "duration": 6.919 }, { "text": "customize this uh class's objects that", "start": 2412.839, "duration": 6.52 }, { "text": "is to say this underscore underscore", "start": 2417.119, "duration": 5.681 }, { "text": "init method or Dunder init method is", "start": 2419.359, "duration": 5.881 }, { "text": "specifically known as an instance method", "start": 2422.8, "duration": 4.279 }, { "text": "and it's called exactly this this is", "start": 2425.24, "duration": 3.92 }, { "text": "designed by the authors of python and if", "start": 2427.079, "duration": 5.441 }, { "text": "you want to initialize the contents of", "start": 2429.16, "duration": 6.0 }, { "text": "an object from a class you define this", "start": 2432.52, "duration": 4.16 }, { "text": "method and we'll see what it's about to", "start": 2435.16, "duration": 4.36 }, { "text": "do here let me go back to vs code and", "start": 2436.68, "duration": 6.0 }, { "text": "let me do something like this self. name", "start": 2439.52, "duration": 8.44 }, { "text": "equals name and self. house equals house", "start": 2442.68, "duration": 7.12 }, { "text": "but I don't want to just init this", "start": 2447.96, "duration": 4.04 }, { "text": "object very generically I want this", "start": 2449.8, "duration": 5.08 }, { "text": "method called in it to take in not just", "start": 2452.0, "duration": 6.599 }, { "text": "self but name comma house as well now", "start": 2454.88, "duration": 5.12 }, { "text": "what in the world is going on because", "start": 2458.599, "duration": 3.0 }, { "text": "there's a lot of weird syntax here", "start": 2460.0, "duration": 3.599 }, { "text": "there's this Dunder init method double", "start": 2461.599, "duration": 4.201 }, { "text": "underscore in it double underscore", "start": 2463.599, "duration": 4.081 }, { "text": "there's all of a sudden this parameter", "start": 2465.8, "duration": 3.84 }, { "text": "called self and then there's this new", "start": 2467.68, "duration": 5.159 }, { "text": "syntax self. name and self. house now", "start": 2469.64, "duration": 5.24 }, { "text": "you're seeing really a manifestation of", "start": 2472.839, "duration": 4.321 }, { "text": "objectoriented programming it's not all", "start": 2474.88, "duration": 3.52 }, { "text": "that different fundamentally from what", "start": 2477.16, "duration": 2.48 }, { "text": "we've been doing for weeks with", "start": 2478.4, "duration": 3.76 }, { "text": "dictionaries by adding keys to", "start": 2479.64, "duration": 4.6 }, { "text": "dictionaries but in this case we're", "start": 2482.16, "duration": 6.199 }, { "text": "adding variables to to objects AKA", "start": 2484.24, "duration": 6.48 }, { "text": "instance variables to objects now what's", "start": 2488.359, "duration": 4.201 }, { "text": "going on let's do this in Reverse let's", "start": 2490.72, "duration": 3.24 }, { "text": "go back to the line of code we wrote", "start": 2492.56, "duration": 4.559 }, { "text": "earlier on line 15 I am treating the", "start": 2493.96, "duration": 5.72 }, { "text": "name of this class student with a", "start": 2497.119, "duration": 6.401 }, { "text": "capital S as a function and I am passing", "start": 2499.68, "duration": 6.639 }, { "text": "in two values name and house what I've", "start": 2503.52, "duration": 4.2 }, { "text": "highlighted here on the screen on line", "start": 2506.319, "duration": 4.321 }, { "text": "15 is generally known as a Constructor", "start": 2507.72, "duration": 5.28 }, { "text": "call this is a line of code that is", "start": 2510.64, "duration": 5.56 }, { "text": "going to construct a student object form", "start": 2513.0, "duration": 6.119 }, { "text": "for me using synonyms it is going to", "start": 2516.2, "duration": 7.0 }, { "text": "instantiate a student object for me and", "start": 2519.119, "duration": 6.041 }, { "text": "again how is it going to create that", "start": 2523.2, "duration": 3.56 }, { "text": "object it's going to use the student", "start": 2525.16, "duration": 4.32 }, { "text": "class as a template as a mold of sorts", "start": 2526.76, "duration": 5.04 }, { "text": "so that every student is structured the", "start": 2529.48, "duration": 3.96 }, { "text": "same every student is going to have a", "start": 2531.8, "duration": 2.96 }, { "text": "name every student's going to have a", "start": 2533.44, "duration": 4.36 }, { "text": "house but because I can pass in", "start": 2534.76, "duration": 5.0 }, { "text": "arguments to this student function", "start": 2537.8, "duration": 4.68 }, { "text": "capital S I'm going to be able to", "start": 2539.76, "duration": 7.04 }, { "text": "customize the contents of that object so", "start": 2542.48, "duration": 5.76 }, { "text": "if you think about the real world if", "start": 2546.8, "duration": 3.0 }, { "text": "you've ever been on a street or a", "start": 2548.24, "duration": 3.44 }, { "text": "neighborhood where all of the houses", "start": 2549.8, "duration": 4.799 }, { "text": "kind of look the same but they're might", "start": 2551.68, "duration": 4.52 }, { "text": "be painted differently they might be", "start": 2554.599, "duration": 2.96 }, { "text": "decorated a little bit differently on", "start": 2556.2, "duration": 3.28 }, { "text": "the outside all of those houses might", "start": 2557.559, "duration": 3.681 }, { "text": "have been built using the exact same", "start": 2559.48, "duration": 4.68 }, { "text": "blueprint sort of a mold if you will but", "start": 2561.24, "duration": 4.92 }, { "text": "then you can specialize exactly the", "start": 2564.16, "duration": 4.36 }, { "text": "finer points of those houses by painting", "start": 2566.16, "duration": 3.6 }, { "text": "the outside a different color or", "start": 2568.52, "duration": 3.12 }, { "text": "planting different trees you can style", "start": 2569.76, "duration": 4.799 }, { "text": "them differently similar uh in spirit", "start": 2571.64, "duration": 5.16 }, { "text": "here we have a student", "start": 2574.559, "duration": 4.361 }, { "text": "blueprint that's always going to have", "start": 2576.8, "duration": 4.2 }, { "text": "now a name and a house but it's up to", "start": 2578.92, "duration": 4.0 }, { "text": "you and me to pass in any name in any", "start": 2581.0, "duration": 4.24 }, { "text": "house that we want now where is this", "start": 2582.92, "duration": 4.0 }, { "text": "function the fact that I'm calling", "start": 2585.24, "duration": 3.76 }, { "text": "student capital S and then a parenthesis", "start": 2586.92, "duration": 3.88 }, { "text": "and a Clos parenthesis with arguments", "start": 2589.0, "duration": 3.48 }, { "text": "inside suggests that there's a function", "start": 2590.8, "duration": 3.6 }, { "text": "somewhere in the world that has been", "start": 2592.48, "duration": 4.24 }, { "text": "defined with de that's going to be", "start": 2594.4, "duration": 4.64 }, { "text": "called well as you might have guessed by", "start": 2596.72, "duration": 4.839 }, { "text": "now the function that will always be", "start": 2599.04, "duration": 5.279 }, { "text": "called by definition of how python", "start": 2601.559, "duration": 5.961 }, { "text": "classes work is a fun called double", "start": 2604.319, "duration": 6.081 }, { "text": "underscore in it double underscore why", "start": 2607.52, "duration": 4.76 }, { "text": "it's a crazy name but it's what the", "start": 2610.4, "duration": 4.199 }, { "text": "authors of python chose to just", "start": 2612.28, "duration": 3.799 }, { "text": "implement the", "start": 2614.599, "duration": 4.361 }, { "text": "initialization of an object in Python", "start": 2616.079, "duration": 5.201 }, { "text": "now the only weird thing especially", "start": 2618.96, "duration": 4.32 }, { "text": "weird thing I will admit is this it", "start": 2621.28, "duration": 4.92 }, { "text": "would be way clearer to me too if the", "start": 2623.28, "duration": 5.96 }, { "text": "only two parameters for in it were just", "start": 2626.2, "duration": 4.84 }, { "text": "name comma house right that's how we've", "start": 2629.24, "duration": 3.8 }, { "text": "defined every function thus far in the", "start": 2631.04, "duration": 4.4 }, { "text": "class you just specify the parameters", "start": 2633.04, "duration": 4.519 }, { "text": "that you want the function to accept and", "start": 2635.44, "duration": 3.76 }, { "text": "indeed that lines up with what I'm doing", "start": 2637.559, "duration": 4.401 }, { "text": "on line 15 I am only passing in two", "start": 2639.2, "duration": 6.32 }, { "text": "things to the student function but it", "start": 2641.96, "duration": 5.879 }, { "text": "turns out that the authors of python", "start": 2645.52, "duration": 3.76 }, { "text": "need to give us a little bit of help", "start": 2647.839, "duration": 3.641 }, { "text": "here because suppose that you pass in", "start": 2649.28, "duration": 5.559 }, { "text": "name and house to this init method and a", "start": 2651.48, "duration": 5.48 }, { "text": "method is just a function inside of a", "start": 2654.839, "duration": 4.201 }, { "text": "class what are you going to do with the", "start": 2656.96, "duration": 4.159 }, { "text": "name in the house like literally where", "start": 2659.04, "duration": 4.039 }, { "text": "are you going to put them if you want to", "start": 2661.119, "duration": 4.921 }, { "text": "remember the name in the house for this", "start": 2663.079, "duration": 4.601 }, { "text": "student you've got to be able to store", "start": 2666.04, "duration": 3.84 }, { "text": "those values somewhere and how do you", "start": 2667.68, "duration": 4.8 }, { "text": "store them in the current object that", "start": 2669.88, "duration": 4.12 }, { "text": "has just been", "start": 2672.48, "duration": 3.96 }, { "text": "instantiated well the authors of python", "start": 2674.0, "duration": 3.839 }, { "text": "decided that the convention is going to", "start": 2676.44, "duration": 4.28 }, { "text": "be that this init method also semi", "start": 2677.839, "duration": 5.681 }, { "text": "secretly takes a third argument that has", "start": 2680.72, "duration": 5.119 }, { "text": "to come first by convention it's called", "start": 2683.52, "duration": 3.72 }, { "text": "self but you could call it technically", "start": 2685.839, "duration": 2.841 }, { "text": "anything you want but the convention is", "start": 2687.24, "duration": 4.24 }, { "text": "to always call it self and self as its", "start": 2688.68, "duration": 5.28 }, { "text": "name implies gives you access to the", "start": 2691.48, "duration": 4.48 }, { "text": "current object that was just created", "start": 2693.96, "duration": 5.04 }, { "text": "created what does that mean again now on", "start": 2695.96, "duration": 5.2 }, { "text": "line 14 now that it's moved down a", "start": 2699.0, "duration": 4.319 }, { "text": "little bit this line here is a", "start": 2701.16, "duration": 4.52 }, { "text": "Constructor it constructs a student", "start": 2703.319, "duration": 4.04 }, { "text": "object but there's nothing in that", "start": 2705.68, "duration": 3.439 }, { "text": "object initially there's no name there's", "start": 2707.359, "duration": 4.2 }, { "text": "no house but the object exists in the", "start": 2709.119, "duration": 4.801 }, { "text": "computer's memory it's up to now you to", "start": 2711.559, "duration": 4.401 }, { "text": "store the name and the house inside of", "start": 2713.92, "duration": 3.8 }, { "text": "that object how do you do that well", "start": 2715.96, "duration": 4.119 }, { "text": "python will just automatically call this", "start": 2717.72, "duration": 4.359 }, { "text": "init method for you and it's going to", "start": 2720.079, "duration": 6.081 }, { "text": "automatically pass in a reference to a", "start": 2722.079, "duration": 6.921 }, { "text": "an argument that represents the current", "start": 2726.16, "duration": 5.04 }, { "text": "object that it just constructed in", "start": 2729.0, "duration": 4.319 }, { "text": "memory for you and it's up to you to", "start": 2731.2, "duration": 4.08 }, { "text": "populate it with values and what this", "start": 2733.319, "duration": 4.321 }, { "text": "means is that inside of your init method", "start": 2735.28, "duration": 5.039 }, { "text": "you can literally do self. name to", "start": 2737.64, "duration": 5.919 }, { "text": "create a new attribute AKA an instance", "start": 2740.319, "duration": 5.841 }, { "text": "variable inside of that otherwise empty", "start": 2743.559, "duration": 4.961 }, { "text": "object and put this name inside of it it", "start": 2746.16, "duration": 4.8 }, { "text": "allows you to do self. house and store", "start": 2748.52, "duration": 4.36 }, { "text": "that value of house now you could call", "start": 2750.96, "duration": 3.08 }, { "text": "these things anything you want they", "start": 2752.88, "duration": 3.04 }, { "text": "could be n they could be H as before", "start": 2754.04, "duration": 5.36 }, { "text": "four but that's really not very self uh", "start": 2755.92, "duration": 5.639 }, { "text": "explanatory much better to do this kind", "start": 2759.4, "duration": 4.919 }, { "text": "of convention self. name equals name", "start": 2761.559, "duration": 5.241 }, { "text": "self. house equals house and this is", "start": 2764.319, "duration": 5.52 }, { "text": "like installing into the otherwise empty", "start": 2766.8, "duration": 5.92 }, { "text": "object the value name and house and", "start": 2769.839, "duration": 5.641 }, { "text": "storing them in really identically named", "start": 2772.72, "duration": 5.04 }, { "text": "instance variables in the object and", "start": 2775.48, "duration": 4.359 }, { "text": "again an object is just an instance of a", "start": 2777.76, "duration": 4.4 }, { "text": "class now I know that was a lot of", "start": 2779.839, "duration": 4.801 }, { "text": "vocabulary that's a lot of weird syntax", "start": 2782.16, "duration": 5.52 }, { "text": "so any questions on this init method", "start": 2784.64, "duration": 4.56 }, { "text": "whose purpose in life again is to", "start": 2787.68, "duration": 4.439 }, { "text": "initialize an otherwise empty object", "start": 2789.2, "duration": 4.84 }, { "text": "when you first create it so what is the", "start": 2792.119, "duration": 4.121 }, { "text": "difference between the init method and", "start": 2794.04, "duration": 5.079 }, { "text": "default Constructor a good question so", "start": 2796.24, "duration": 4.839 }, { "text": "in other languages if you programmed", "start": 2799.119, "duration": 4.48 }, { "text": "before for instance Java there are", "start": 2801.079, "duration": 4.201 }, { "text": "functions that are explicitly called", "start": 2803.599, "duration": 3.881 }, { "text": "Constructors that indeed construct an", "start": 2805.28, "duration": 4.319 }, { "text": "object they initialize it with values", "start": 2807.48, "duration": 3.92 }, { "text": "python technically calls this init", "start": 2809.599, "duration": 3.841 }, { "text": "method the initialization method it", "start": 2811.4, "duration": 5.4 }, { "text": "initializes the value it's online 14 uh", "start": 2813.44, "duration": 5.72 }, { "text": "line 15 now of my code if I scroll back", "start": 2816.8, "duration": 4.72 }, { "text": "down that I'm technically constructing", "start": 2819.16, "duration": 5.0 }, { "text": "the object it turns out there's another", "start": 2821.52, "duration": 4.2 }, { "text": "special method in Python that we won't", "start": 2824.16, "duration": 3.6 }, { "text": "talk about in detail today called", "start": 2825.72, "duration": 4.599 }, { "text": "underscore uncore new underscore", "start": 2827.76, "duration": 4.559 }, { "text": "underscore that actually handles the", "start": 2830.319, "duration": 4.04 }, { "text": "process of creating an empty object in", "start": 2832.319, "duration": 4.721 }, { "text": "memory for us but generally speaking you", "start": 2834.359, "duration": 4.641 }, { "text": "the programmer don't need to manipulate", "start": 2837.04, "duration": 4.0 }, { "text": "the new function it just works for you", "start": 2839.0, "duration": 4.319 }, { "text": "instead you define your own init method", "start": 2841.04, "duration": 4.279 }, { "text": "here an init function inside of your", "start": 2843.319, "duration": 4.881 }, { "text": "class and that method initializes the", "start": 2845.319, "duration": 5.161 }, { "text": "contents of the object so there's", "start": 2848.2, "duration": 3.48 }, { "text": "technically a distinction between", "start": 2850.48, "duration": 3.04 }, { "text": "constructing the object with new and", "start": 2851.68, "duration": 3.84 }, { "text": "initializing it with in it but in the", "start": 2853.52, "duration": 3.76 }, { "text": "world of python you pretty much only", "start": 2855.52, "duration": 4.48 }, { "text": "worry about the in it method python", "start": 2857.28, "duration": 5.12 }, { "text": "generally does the other part for you a", "start": 2860.0, "duration": 4.8 }, { "text": "good question others uh what about if", "start": 2862.4, "duration": 5.439 }, { "text": "you want to store more than one name or", "start": 2864.8, "duration": 4.96 }, { "text": "more than one house a good question if", "start": 2867.839, "duration": 3.881 }, { "text": "you want to store more than one name or", "start": 2869.76, "duration": 3.4 }, { "text": "more than one house you can do this in", "start": 2871.72, "duration": 3.359 }, { "text": "different ways you could create other", "start": 2873.16, "duration": 4.159 }, { "text": "attributes technically called instance", "start": 2875.079, "duration": 6.161 }, { "text": "variables like self. name one self. name", "start": 2877.319, "duration": 5.961 }, { "text": "two but we've seen in the past that that", "start": 2881.24, "duration": 3.72 }, { "text": "is not a very good design just to have", "start": 2883.28, "duration": 3.4 }, { "text": "multiple variables to store multiple", "start": 2884.96, "duration": 3.8 }, { "text": "things maybe instead you have an", "start": 2886.68, "duration": 5.159 }, { "text": "instance variable called self. names", "start": 2888.76, "duration": 5.68 }, { "text": "plural and you set it equal to a list of", "start": 2891.839, "duration": 5.121 }, { "text": "names or a list of houses now in this", "start": 2894.44, "duration": 3.879 }, { "text": "case I don't think that really solves a", "start": 2896.96, "duration": 2.639 }, { "text": "problem because I'm trying to implement", "start": 2898.319, "duration": 4.0 }, { "text": "a student singular so it doesn't really", "start": 2899.599, "duration": 4.641 }, { "text": "make sense to have multiple first names", "start": 2902.319, "duration": 3.721 }, { "text": "maybe a nickname maybe a last name so we", "start": 2904.24, "duration": 3.56 }, { "text": "could add those to but I don't think we", "start": 2906.04, "duration": 3.68 }, { "text": "need multiple names per se and in this", "start": 2907.8, "duration": 4.319 }, { "text": "case multiple houses but absolutely you", "start": 2909.72, "duration": 3.96 }, { "text": "could do that using some of our familiar", "start": 2912.119, "duration": 4.121 }, { "text": "building blocks like lists other", "start": 2913.68, "duration": 4.8 }, { "text": "questions how are classes or objects", "start": 2916.24, "duration": 4.68 }, { "text": "represented in memory how are classes", "start": 2918.48, "duration": 4.52 }, { "text": "and objects represented in memory so the", "start": 2920.92, "duration": 4.72 }, { "text": "class is technically just code it is the", "start": 2923.0, "duration": 4.559 }, { "text": "code on the top of my file lines one", "start": 2925.64, "duration": 3.679 }, { "text": "through four that defines that", "start": 2927.559, "duration": 4.76 }, { "text": "blueprints that template if you will um", "start": 2929.319, "duration": 5.081 }, { "text": "objects are stored in the computer's", "start": 2932.319, "duration": 3.8 }, { "text": "memory by taking up some number of byes", "start": 2934.4, "duration": 3.08 }, { "text": "so you're probably familiar with bytes", "start": 2936.119, "duration": 3.96 }, { "text": "or kilobytes or megabytes there's some", "start": 2937.48, "duration": 4.68 }, { "text": "chunk of bytes probably all in the same", "start": 2940.079, "duration": 4.641 }, { "text": "location in the computer's memory or Ram", "start": 2942.16, "duration": 5.0 }, { "text": "where those V where those objects are", "start": 2944.72, "duration": 5.24 }, { "text": "stored but that's what python the", "start": 2947.16, "duration": 4.72 }, { "text": "program handles for you python The", "start": 2949.96, "duration": 3.68 }, { "text": "Interpreter figures out where in the", "start": 2951.88, "duration": 3.439 }, { "text": "computer's memory to put it you and I", "start": 2953.64, "duration": 3.24 }, { "text": "the programmers get to think and solve", "start": 2955.319, "duration": 3.48 }, { "text": "problems at this level python The", "start": 2956.88, "duration": 3.919 }, { "text": "Interpreter handles those lower level", "start": 2958.799, "duration": 3.961 }, { "text": "details for you how about one final", "start": 2960.799, "duration": 4.841 }, { "text": "question on classes and objects no my", "start": 2962.76, "duration": 5.44 }, { "text": "question is if we can the same do the", "start": 2965.64, "duration": 4.919 }, { "text": "same thing with the dictionary so where", "start": 2968.2, "duration": 4.8 }, { "text": "to use classes good question if you can", "start": 2970.559, "duration": 3.601 }, { "text": "do the same things as you can with", "start": 2973.0, "duration": 3.04 }, { "text": "dictionaries why should you use classes", "start": 2974.16, "duration": 3.12 }, { "text": "because we are just scratching the", "start": 2976.04, "duration": 3.039 }, { "text": "surface now of what you can do with", "start": 2977.28, "duration": 4.36 }, { "text": "classes allow me to go back now to my", "start": 2979.079, "duration": 4.24 }, { "text": "keyboard and show you more of what you", "start": 2981.64, "duration": 4.12 }, { "text": "can do with classes but in short you can", "start": 2983.319, "duration": 5.561 }, { "text": "do much more with classes you can ensure", "start": 2985.76, "duration": 5.24 }, { "text": "the correctness of your data much more", "start": 2988.88, "duration": 4.199 }, { "text": "with classes you can error check things", "start": 2991.0, "duration": 3.76 }, { "text": "and generally you can design more", "start": 2993.079, "duration": 3.641 }, { "text": "complicated soft software more", "start": 2994.76, "duration": 3.52 }, { "text": "effectively and we'll continue to see", "start": 2996.72, "duration": 3.76 }, { "text": "today features of python and", "start": 2998.28, "duration": 3.44 }, { "text": "objectoriented programming more", "start": 3000.48, "duration": 4.4 }, { "text": "generally that allows us to do just that", "start": 3001.72, "duration": 6.079 }, { "text": "so let me propose in fact that first", "start": 3004.88, "duration": 4.36 }, { "text": "let's just tighten up this current", "start": 3007.799, "duration": 3.76 }, { "text": "implementation which again has us with", "start": 3009.24, "duration": 4.559 }, { "text": "an init method that just declares two", "start": 3011.559, "duration": 4.52 }, { "text": "instance variables self. name and self.", "start": 3013.799, "duration": 3.8 }, { "text": "house which again just creates those", "start": 3016.079, "duration": 4.361 }, { "text": "variables inside of the otherwise empty", "start": 3017.599, "duration": 4.881 }, { "text": "object and assigns them values name and", "start": 3020.44, "duration": 3.96 }, { "text": "house respectively let me go ahead and", "start": 3022.48, "duration": 3.639 }, { "text": "just do one little thing here I don't", "start": 3024.4, "duration": 3.6 }, { "text": "really need this student variable let me", "start": 3026.119, "duration": 3.841 }, { "text": "just tighten this up so that each time", "start": 3028.0, "duration": 4.0 }, { "text": "we improve or change the code we're", "start": 3029.96, "duration": 4.08 }, { "text": "focusing really on just the minimal", "start": 3032.0, "duration": 4.4 }, { "text": "changes alone so I've not fundamentally", "start": 3034.04, "duration": 3.92 }, { "text": "done anything different I just got rid", "start": 3036.4, "duration": 2.8 }, { "text": "of the variable name and I'm just", "start": 3037.96, "duration": 3.92 }, { "text": "returning the return value of this", "start": 3039.2, "duration": 4.96 }, { "text": "student function that's constructing my", "start": 3041.88, "duration": 3.959 }, { "text": "new object for me so I'm just tightening", "start": 3044.16, "duration": 3.56 }, { "text": "things up as we've done many times in", "start": 3045.839, "duration": 4.76 }, { "text": "the past well what if something goes", "start": 3047.72, "duration": 5.8 }, { "text": "wrong when in creating this student for", "start": 3050.599, "duration": 4.681 }, { "text": "instance what if the user does not give", "start": 3053.52, "duration": 3.92 }, { "text": "us a name and they just hit enter when", "start": 3055.28, "duration": 4.079 }, { "text": "prompted for name like I don't want to", "start": 3057.44, "duration": 4.24 }, { "text": "put in my computer's memory a sort of", "start": 3059.359, "duration": 4.76 }, { "text": "bogus student object that has no name", "start": 3061.68, "duration": 4.2 }, { "text": "right I'd ideally like to check for", "start": 3064.119, "duration": 3.841 }, { "text": "errors before I even create it so I", "start": 3065.88, "duration": 3.88 }, { "text": "don't create a nameless student it would", "start": 3067.96, "duration": 3.92 }, { "text": "just be weird and probably a bug to have", "start": 3069.76, "duration": 5.039 }, { "text": "an object that has no name similarly I", "start": 3071.88, "duration": 4.199 }, { "text": "don't want the user to be able to type", "start": 3074.799, "duration": 3.961 }, { "text": "in something random as their house at", "start": 3076.079, "duration": 4.641 }, { "text": "least in the World of Harry Potter", "start": 3078.76, "duration": 3.799 }, { "text": "there's really only four houses at", "start": 3080.72, "duration": 3.52 }, { "text": "Hogwarts at least or there's again", "start": 3082.559, "duration": 4.081 }, { "text": "Gryffindor and huffle and Ravenclaw and", "start": 3084.24, "duration": 5.48 }, { "text": "slitherin a list of four valid houses it", "start": 3086.64, "duration": 5.76 }, { "text": "would be nice if I somehow validated", "start": 3089.72, "duration": 4.92 }, { "text": "that the user's input is indeed in that", "start": 3092.4, "duration": 5.159 }, { "text": "list now I could do all of that", "start": 3094.64, "duration": 5.439 }, { "text": "validation in my get student function I", "start": 3097.559, "duration": 5.081 }, { "text": "could check is the name empty if so", "start": 3100.079, "duration": 4.76 }, { "text": "don't create the student object is the", "start": 3102.64, "duration": 4.64 }, { "text": "house one of those four houses if not", "start": 3104.839, "duration": 4.72 }, { "text": "don't create the student object but that", "start": 3107.28, "duration": 4.24 }, { "text": "would be rather decoupled from the", "start": 3109.559, "duration": 3.921 }, { "text": "student itself right get student", "start": 3111.52, "duration": 4.279 }, { "text": "currently exists as just my own function", "start": 3113.48, "duration": 5.639 }, { "text": "in my student. piy file but classes and", "start": 3115.799, "duration": 5.32 }, { "text": "really object-oriented programming more", "start": 3119.119, "duration": 5.561 }, { "text": "generally encourages you to encapsulate", "start": 3121.119, "duration": 6.841 }, { "text": "inside of a class all functionality", "start": 3124.68, "duration": 5.76 }, { "text": "related to that class so if you want to", "start": 3127.96, "duration": 4.68 }, { "text": "validate that a name exists if you want", "start": 3130.44, "duration": 4.639 }, { "text": "to validate that a house is correct that", "start": 3132.64, "duration": 5.28 }, { "text": "belongs just uh fundamentally in the", "start": 3135.079, "duration": 5.48 }, { "text": "class called student itself not in some", "start": 3137.92, "duration": 4.72 }, { "text": "random function that you wrote elsewhere", "start": 3140.559, "duration": 4.0 }, { "text": "again this is just methodology because", "start": 3142.64, "duration": 4.0 }, { "text": "again if we think about writing code", "start": 3144.559, "duration": 3.681 }, { "text": "that gets longer and longer more and", "start": 3146.64, "duration": 3.6 }, { "text": "more complicated it should make just", "start": 3148.24, "duration": 3.8 }, { "text": "intuitive sense that if you keep all the", "start": 3150.24, "duration": 4.599 }, { "text": "house uh and all the Stu all of the name", "start": 3152.04, "duration": 4.519 }, { "text": "and all of the house related code in the", "start": 3154.839, "duration": 3.601 }, { "text": "student it's just better organization", "start": 3156.559, "duration": 3.681 }, { "text": "right keep all of the related code", "start": 3158.44, "duration": 3.28 }, { "text": "together and that's probably going to", "start": 3160.24, "duration": 3.2 }, { "text": "set you up for more success and indeed", "start": 3161.72, "duration": 3.48 }, { "text": "that's part of this methodology of", "start": 3163.44, "duration": 4.24 }, { "text": "objectoriented programming let me go", "start": 3165.2, "duration": 6.56 }, { "text": "ahead now and change my students classes", "start": 3167.68, "duration": 7.84 }, { "text": "init method to do this if the name is", "start": 3171.76, "duration": 6.44 }, { "text": "blank so if not name and we've seen this", "start": 3175.52, "duration": 4.48 }, { "text": "kind of syntax before if you say in", "start": 3178.2, "duration": 5.0 }, { "text": "Python pythonic if not name that's like", "start": 3180.0, "duration": 5.72 }, { "text": "doing something like this if name equals", "start": 3183.2, "duration": 4.84 }, { "text": "equals quote unquote but I can do this a", "start": 3185.72, "duration": 4.0 }, { "text": "little more elegantly just say if not", "start": 3188.04, "duration": 3.4 }, { "text": "name would be the more pythonic way to", "start": 3189.72, "duration": 5.8 }, { "text": "do it well I want to return an error", "start": 3191.44, "duration": 5.44 }, { "text": "like I might want to do something like", "start": 3195.52, "duration": 4.16 }, { "text": "this print missing name but this is not", "start": 3196.88, "duration": 5.6 }, { "text": "good enough it does not suffice to just", "start": 3199.68, "duration": 4.919 }, { "text": "print out missing name and then let the", "start": 3202.48, "duration": 3.839 }, { "text": "rest of the code go through all right", "start": 3204.599, "duration": 3.48 }, { "text": "well what could I do instead in the past", "start": 3206.319, "duration": 3.321 }, { "text": "we've seen another technique I could do", "start": 3208.079, "duration": 3.961 }, { "text": "cy. exit and I could say something like", "start": 3209.64, "duration": 3.919 }, { "text": "missing name and I could go up here and", "start": 3212.04, "duration": 3.759 }, { "text": "I could import CIS but this is a really", "start": 3213.559, "duration": 4.8 }, { "text": "obnoxious solution to the problem just", "start": 3215.799, "duration": 5.0 }, { "text": "because you or maybe a colleague messed", "start": 3218.359, "duration": 4.881 }, { "text": "up and called a function with an invalid", "start": 3220.799, "duration": 4.121 }, { "text": "name you're going to quit my whole", "start": 3223.24, "duration": 4.599 }, { "text": "program like that's really really", "start": 3224.92, "duration": 5.56 }, { "text": "extreme of a response and you probably", "start": 3227.839, "duration": 4.121 }, { "text": "don't want to do that if your program's", "start": 3230.48, "duration": 2.879 }, { "text": "in the middle of running you might want", "start": 3231.96, "duration": 2.96 }, { "text": "to clean some stuff up you might want to", "start": 3233.359, "duration": 3.561 }, { "text": "save files you don't want to just exit a", "start": 3234.92, "duration": 4.399 }, { "text": "program sometimes in some arbitrary line", "start": 3236.92, "duration": 4.439 }, { "text": "just because input was invalid so I", "start": 3239.319, "duration": 4.0 }, { "text": "don't think we want to do that either", "start": 3241.359, "duration": 4.72 }, { "text": "but we do now have a mechanism for", "start": 3243.319, "duration": 5.121 }, { "text": "signaling errors unfortunately I can't", "start": 3246.079, "duration": 3.72 }, { "text": "do something like this I could try", "start": 3248.44, "duration": 4.32 }, { "text": "returning none and say uhuh this student", "start": 3249.799, "duration": 4.32 }, { "text": "does not exist I'm going to hand you", "start": 3252.76, "duration": 4.319 }, { "text": "back none instead but it's too late if", "start": 3254.119, "duration": 4.521 }, { "text": "we scroll back down to where I'm", "start": 3257.079, "duration": 4.48 }, { "text": "creating the student it's on line 17 now", "start": 3258.64, "duration": 4.719 }, { "text": "where I've highlighted this code the", "start": 3261.559, "duration": 4.04 }, { "text": "student has already been created", "start": 3263.359, "duration": 4.0 }, { "text": "there is an object somewhere in the", "start": 3265.599, "duration": 4.361 }, { "text": "computer's memory that's structured as a", "start": 3267.359, "duration": 4.361 }, { "text": "student it just doesn't have any values", "start": 3269.96, "duration": 4.44 }, { "text": "inside of it but it's too late therefore", "start": 3271.72, "duration": 5.119 }, { "text": "to return none that ship has sailed the", "start": 3274.4, "duration": 4.52 }, { "text": "object exists you can't just suddenly", "start": 3276.839, "duration": 3.681 }, { "text": "say nope nope there is no object there", "start": 3278.92, "duration": 3.96 }, { "text": "is an object it's up to you to Signal an", "start": 3280.52, "duration": 4.799 }, { "text": "error and how do you signal an error", "start": 3282.88, "duration": 4.199 }, { "text": "well we've actually seen this before but", "start": 3285.319, "duration": 3.321 }, { "text": "we haven't had occasion to create our", "start": 3287.079, "duration": 4.161 }, { "text": "own errors it turns out in Python", "start": 3288.64, "duration": 5.199 }, { "text": "there's another keyword related to", "start": 3291.24, "duration": 5.4 }, { "text": "exceptions that python itself uses to", "start": 3293.839, "duration": 4.641 }, { "text": "raise all of those exceptions we've", "start": 3296.64, "duration": 3.479 }, { "text": "talked about in the past when you've", "start": 3298.48, "duration": 4.839 }, { "text": "caught things like value errors or other", "start": 3300.119, "duration": 5.48 }, { "text": "such exceptions that come with python", "start": 3303.319, "duration": 5.0 }, { "text": "well it turns out you the programmer can", "start": 3305.599, "duration": 5.441 }, { "text": "raise that is create your own exceptions", "start": 3308.319, "duration": 4.48 }, { "text": "when something just really goes wrong", "start": 3311.04, "duration": 3.12 }, { "text": "not wrong enough that you want to quit", "start": 3312.799, "duration": 3.52 }, { "text": "and exit the whole program but enough", "start": 3314.16, "duration": 4.0 }, { "text": "that you need to somehow alert the", "start": 3316.319, "duration": 4.24 }, { "text": "programmer that there has been an error", "start": 3318.16, "duration": 5.04 }, { "text": "something exceptional in a very bad way", "start": 3320.559, "duration": 4.681 }, { "text": "something exceptional has happened and", "start": 3323.2, "duration": 5.399 }, { "text": "let them try to catch that exception as", "start": 3325.24, "duration": 6.04 }, { "text": "needed so let me go back to vs code here", "start": 3328.599, "duration": 5.72 }, { "text": "and propose that if the user passes in", "start": 3331.28, "duration": 5.279 }, { "text": "an invalid name it's just empty so", "start": 3334.319, "duration": 4.321 }, { "text": "there's not a name well what I really", "start": 3336.559, "duration": 5.201 }, { "text": "want to do is this I want to raise a", "start": 3338.64, "duration": 5.6 }, { "text": "value error and we've seen the value", "start": 3341.76, "duration": 4.88 }, { "text": "errors before we've created value errors", "start": 3344.24, "duration": 4.319 }, { "text": "accidentally before and generally you", "start": 3346.64, "duration": 4.199 }, { "text": "and I have try to catch them if they", "start": 3348.559, "duration": 4.48 }, { "text": "happen well the flip side of this", "start": 3350.839, "duration": 4.161 }, { "text": "feature of exceptions in a language like", "start": 3353.039, "duration": 3.76 }, { "text": "python is that you the programmer can", "start": 3355.0, "duration": 3.64 }, { "text": "also raise exceptions when something", "start": 3356.799, "duration": 4.32 }, { "text": "exceptional happens and you can even be", "start": 3358.64, "duration": 4.04 }, { "text": "more precise you don't have to raise a", "start": 3361.119, "duration": 3.2 }, { "text": "generic value error and let the", "start": 3362.68, "duration": 3.52 }, { "text": "programmer figure out what went wrong", "start": 3364.319, "duration": 4.04 }, { "text": "you can treat value error and all", "start": 3366.2, "duration": 4.32 }, { "text": "exceptions in Python like functions and", "start": 3368.359, "duration": 4.801 }, { "text": "actually pass to them a an explanatory", "start": 3370.52, "duration": 5.24 }, { "text": "message like quote unquote missing name", "start": 3373.16, "duration": 4.04 }, { "text": "so that at least the programmer when", "start": 3375.76, "duration": 2.88 }, { "text": "they encounter this error knows oh I", "start": 3377.2, "duration": 3.72 }, { "text": "messed up I didn't make sure that the", "start": 3378.64, "duration": 5.52 }, { "text": "user has a name and now what do you want", "start": 3380.92, "duration": 5.36 }, { "text": "to do instead well now if you're the", "start": 3384.16, "duration": 4.04 }, { "text": "programmer you could do something like", "start": 3386.28, "duration": 6.039 }, { "text": "this you could try to create a student", "start": 3388.2, "duration": 7.359 }, { "text": "except if there's a value error then you", "start": 3392.319, "duration": 4.961 }, { "text": "could handle it in some way and I'm", "start": 3395.559, "duration": 3.8 }, { "text": "going to wave my hand with a dot dot dot", "start": 3397.28, "duration": 3.88 }, { "text": "at how you would handle it but you would", "start": 3399.359, "duration": 3.96 }, { "text": "handle it using try and accept just like", "start": 3401.16, "duration": 4.439 }, { "text": "we have in the past and that would allow", "start": 3403.319, "duration": 4.321 }, { "text": "you the programmer to try to create the", "start": 3405.599, "duration": 3.841 }, { "text": "student but if something goes wrong okay", "start": 3407.64, "duration": 4.84 }, { "text": "okay I'll handle it nonetheless so", "start": 3409.44, "duration": 4.84 }, { "text": "what's new here again is this raise", "start": 3412.48, "duration": 4.319 }, { "text": "keyword that just lets you and I", "start": 3414.28, "duration": 4.92 }, { "text": "actually raise our own exceptions to", "start": 3416.799, "duration": 4.32 }, { "text": "Signal these errors well let me go back", "start": 3419.2, "duration": 4.119 }, { "text": "to my code here and I'm just going to go", "start": 3421.119, "duration": 4.48 }, { "text": "ahead and not bother trying or catching", "start": 3423.319, "duration": 4.24 }, { "text": "this error for now we'll just focus on", "start": 3425.599, "duration": 4.041 }, { "text": "raising it and assume that from our week", "start": 3427.559, "duration": 4.24 }, { "text": "on exceptions you could add try and", "start": 3429.64, "duration": 4.6 }, { "text": "accept as needed in places let me go", "start": 3431.799, "duration": 4.401 }, { "text": "back to the code here and propose that", "start": 3434.24, "duration": 3.92 }, { "text": "something else could go wrong with house", "start": 3436.2, "duration": 3.839 }, { "text": "right if there is a name we're good but", "start": 3438.16, "duration": 3.8 }, { "text": "if we're given a house but it's invalid", "start": 3440.039, "duration": 3.961 }, { "text": "we should probably raise an exception", "start": 3441.96, "duration": 4.48 }, { "text": "for that too so what if we do this if", "start": 3444.0, "duration": 5.839 }, { "text": "house is not in the list containing", "start": 3446.44, "duration": 6.52 }, { "text": "Gryffindor quote unquote uh Hufflepuff", "start": 3449.839, "duration": 6.081 }, { "text": "quote unquote uh let's see Ravenclaw", "start": 3452.96, "duration": 6.24 }, { "text": "quote unquote or uh Slytherin quote", "start": 3455.92, "duration": 6.08 }, { "text": "unquote then with my colon let's raise", "start": 3459.2, "duration": 4.52 }, { "text": "another type of value error but rather", "start": 3462.0, "duration": 3.72 }, { "text": "than raise a generic value error let's", "start": 3463.72, "duration": 4.28 }, { "text": "pass in an argument quote unquote", "start": 3465.72, "duration": 6.04 }, { "text": "invalid house and so here we now see a", "start": 3468.0, "duration": 6.039 }, { "text": "capability that we can do with classes", "start": 3471.76, "duration": 4.839 }, { "text": "that we can't with dictionaries if you", "start": 3474.039, "duration": 5.601 }, { "text": "add an attribute to a dictionary a key", "start": 3476.599, "duration": 5.041 }, { "text": "to a dictionary it's going in no matter", "start": 3479.64, "duration": 4.32 }, { "text": "what even if the name is empty even if", "start": 3481.64, "duration": 4.28 }, { "text": "the house is a completely random string", "start": 3483.96, "duration": 3.399 }, { "text": "of text that's not one of these four", "start": 3485.92, "duration": 3.52 }, { "text": "houses it's going into that dictionary", "start": 3487.359, "duration": 4.401 }, { "text": "but with the class and by way of this", "start": 3489.44, "duration": 5.44 }, { "text": "init method you and I can now control", "start": 3491.76, "duration": 5.44 }, { "text": "exactly what's going to be installed if", "start": 3494.88, "duration": 4.28 }, { "text": "you will inside of this object you have", "start": 3497.2, "duration": 4.399 }, { "text": "a little more control now over", "start": 3499.16, "duration": 4.639 }, { "text": "correctness and so now let me go ahead", "start": 3501.599, "duration": 4.601 }, { "text": "and uh scroll back down to my terminal", "start": 3503.799, "duration": 4.681 }, { "text": "window and clear it let me run python of", "start": 3506.2, "duration": 4.359 }, { "text": "studenty let me type in something like", "start": 3508.48, "duration": 4.92 }, { "text": "Harry let me type in Gryffindor enter", "start": 3510.559, "duration": 4.28 }, { "text": "and we see that indeed Harry is from", "start": 3513.4, "duration": 3.84 }, { "text": "Gryffindor what if I made a mistake", "start": 3514.839, "duration": 4.52 }, { "text": "though what if I ran python of student.", "start": 3517.24, "duration": 4.079 }, { "text": "and typed Harry is the name but I this", "start": 3519.359, "duration": 4.801 }, { "text": "time typed in number four Private Drive", "start": 3521.319, "duration": 4.52 }, { "text": "which is where he grew up instead of his", "start": 3524.16, "duration": 4.04 }, { "text": "proper Hogwarts house let me hit enter", "start": 3525.839, "duration": 5.641 }, { "text": "now and now you see a value error but", "start": 3528.2, "duration": 5.359 }, { "text": "this isn't one that python generated for", "start": 3531.48, "duration": 5.04 }, { "text": "us per se I rais this error and", "start": 3533.559, "duration": 4.681 }, { "text": "therefore if I went in and wrote more", "start": 3536.52, "duration": 3.4 }, { "text": "code in my get student function I could", "start": 3538.24, "duration": 5.359 }, { "text": "also catch this error with our usual try", "start": 3539.92, "duration": 5.8 }, { "text": "except syntax so all we have now is not", "start": 3543.599, "duration": 4.681 }, { "text": "just classes in our toolkit but even", "start": 3545.72, "duration": 5.04 }, { "text": "more Powers when it comes to exceptions", "start": 3548.28, "duration": 4.64 }, { "text": "and not just catching them ourselves but", "start": 3550.76, "duration": 5.559 }, { "text": "raising them ourselves too any questions", "start": 3552.92, "duration": 4.879 }, { "text": "now", "start": 3556.319, "duration": 4.641 }, { "text": "on this use of classes and in it and now", "start": 3557.799, "duration": 5.32 }, { "text": "this ability to raise exceptions when", "start": 3560.96, "duration": 3.96 }, { "text": "something goes wrong inside of the", "start": 3563.119, "duration": 5.161 }, { "text": "initialization so what if user has a", "start": 3564.92, "duration": 6.04 }, { "text": "middle name name middle name and last", "start": 3568.28, "duration": 4.6 }, { "text": "name how would you fix that a good", "start": 3570.96, "duration": 4.32 }, { "text": "question if you wanted the user to if", "start": 3572.88, "duration": 4.28 }, { "text": "you wanted the student to have a first", "start": 3575.28, "duration": 3.799 }, { "text": "name middle name and last name we could", "start": 3577.16, "duration": 4.199 }, { "text": "do this in a bunch of different ways the", "start": 3579.079, "duration": 4.361 }, { "text": "simplest though if Let Me Clear My", "start": 3581.359, "duration": 3.96 }, { "text": "screen here and let me just temporarily", "start": 3583.44, "duration": 4.2 }, { "text": "do this let me propose that the init", "start": 3585.319, "duration": 5.361 }, { "text": "method take in a first argument a middle", "start": 3587.64, "duration": 5.64 }, { "text": "argument and a last argument and then", "start": 3590.68, "duration": 4.439 }, { "text": "what I think I would do down here here", "start": 3593.28, "duration": 4.64 }, { "text": "is ultimately have first equals first", "start": 3595.119, "duration": 4.44 }, { "text": "and then I would do the same thing for", "start": 3597.92, "duration": 5.6 }, { "text": "middle and last so middle and middle and", "start": 3599.559, "duration": 7.04 }, { "text": "then last and last and then what I would", "start": 3603.52, "duration": 6.2 }, { "text": "have to do here is when I actually ask", "start": 3606.599, "duration": 5.24 }, { "text": "the user for their name I might need to", "start": 3609.72, "duration": 3.76 }, { "text": "really go all out I might need to ask", "start": 3611.839, "duration": 3.441 }, { "text": "them first for their first name and", "start": 3613.48, "duration": 3.8 }, { "text": "store that in a variable called First", "start": 3615.28, "duration": 4.12 }, { "text": "and therefore pass in first I might", "start": 3617.28, "duration": 3.72 }, { "text": "similarly need to ask them for their", "start": 3619.4, "duration": 4.08 }, { "text": "middle name and store that in a variable", "start": 3621.0, "duration": 4.039 }, { "text": "and then pass in a second argument", "start": 3623.48, "duration": 3.96 }, { "text": "middle and then lastly if you will let", "start": 3625.039, "duration": 4.08 }, { "text": "me go ahead and create a third variable", "start": 3627.44, "duration": 4.08 }, { "text": "called last get the input for their last", "start": 3629.119, "duration": 5.44 }, { "text": "name and pass that in as well I could", "start": 3631.52, "duration": 5.48 }, { "text": "instead just use one input and just ask", "start": 3634.559, "duration": 4.121 }, { "text": "them for their whole name so type in", "start": 3637.0, "duration": 4.88 }, { "text": "David uh men enter or David J ma all", "start": 3638.68, "duration": 5.359 }, { "text": "three of them and maybe I could use", "start": 3641.88, "duration": 4.56 }, { "text": "Python split function maybe a regular", "start": 3644.039, "duration": 4.04 }, { "text": "expression to tease it apart that's", "start": 3646.44, "duration": 2.919 }, { "text": "probably going to be messy because", "start": 3648.079, "duration": 2.48 }, { "text": "there's going to be people who don't", "start": 3649.359, "duration": 2.921 }, { "text": "have just two or three names they might", "start": 3650.559, "duration": 3.641 }, { "text": "have four or five so maybe sometimes", "start": 3652.28, "duration": 3.88 }, { "text": "it's better to have multiple prompts but", "start": 3654.2, "duration": 3.48 }, { "text": "that's not a problem because with a", "start": 3656.16, "duration": 4.439 }, { "text": "class we have the expressiveness to take", "start": 3657.68, "duration": 4.679 }, { "text": "in more arguments if we want we could", "start": 3660.599, "duration": 3.561 }, { "text": "even take a list if we wanted but I", "start": 3662.359, "duration": 3.0 }, { "text": "think we'd probably want to have even", "start": 3664.16, "duration": 3.0 }, { "text": "more error checking then not just for", "start": 3665.359, "duration": 5.2 }, { "text": "name but for first and then maybe for", "start": 3667.16, "duration": 5.199 }, { "text": "middle and then maybe for last so it", "start": 3670.559, "duration": 3.56 }, { "text": "just is more and more code though there", "start": 3672.359, "duration": 3.801 }, { "text": "would be ways to perhaps consolidate", "start": 3674.119, "duration": 4.44 }, { "text": "that too let me undo all of that and see", "start": 3676.16, "duration": 5.159 }, { "text": "if there are other questions now on", "start": 3678.559, "duration": 5.201 }, { "text": "classes I assume this is classes are", "start": 3681.319, "duration": 4.0 }, { "text": "something I might at the beginning of a", "start": 3683.76, "duration": 3.12 }, { "text": "project can I just put them in a", "start": 3685.319, "duration": 4.0 }, { "text": "different file and import them into my", "start": 3686.88, "duration": 5.719 }, { "text": "project or or or my main code as needed", "start": 3689.319, "duration": 4.76 }, { "text": "absolutely a really good question you", "start": 3692.599, "duration": 2.921 }, { "text": "could imagine wanting to use this", "start": 3694.079, "duration": 4.28 }, { "text": "student class not just in studenty but", "start": 3695.52, "duration": 4.72 }, { "text": "in other files or other projects of", "start": 3698.359, "duration": 4.0 }, { "text": "yours and absolutely you can create your", "start": 3700.24, "duration": 5.16 }, { "text": "own library of classes by putting the", "start": 3702.359, "duration": 5.081 }, { "text": "student class in your own module or", "start": 3705.4, "duration": 3.8 }, { "text": "package per our discussion in the past", "start": 3707.44, "duration": 3.56 }, { "text": "about libraries more generally and", "start": 3709.2, "duration": 3.399 }, { "text": "absolutely you can do that and later", "start": 3711.0, "duration": 3.72 }, { "text": "today will we see that we've actually", "start": 3712.599, "duration": 4.321 }, { "text": "been using classes you and I before in", "start": 3714.72, "duration": 4.119 }, { "text": "third party librar so you too can", "start": 3716.92, "duration": 3.879 }, { "text": "absolutely do the same how about one", "start": 3718.839, "duration": 5.52 }, { "text": "more question on classes can you have", "start": 3720.799, "duration": 6.401 }, { "text": "optional variables in classes and two", "start": 3724.359, "duration": 5.2 }, { "text": "can you have your own error names like", "start": 3727.2, "duration": 4.96 }, { "text": "let's be ego and say I want to raise", "start": 3729.559, "duration": 6.48 }, { "text": "Eric error short answer yes so you can", "start": 3732.16, "duration": 6.28 }, { "text": "uh these init functions are just like", "start": 3736.039, "duration": 3.841 }, { "text": "python functions more generally even", "start": 3738.44, "duration": 2.48 }, { "text": "though they're special and that they're", "start": 3739.88, "duration": 2.64 }, { "text": "going to get called automatically by", "start": 3740.92, "duration": 3.679 }, { "text": "python for you but if you want to make", "start": 3742.52, "duration": 3.519 }, { "text": "house optional you could do something", "start": 3744.599, "duration": 3.041 }, { "text": "like this you could give it a default", "start": 3746.039, "duration": 5.641 }, { "text": "value in the init functions uh signature", "start": 3747.64, "duration": 5.679 }, { "text": "so to speak in that first line of code", "start": 3751.68, "duration": 3.76 }, { "text": "on line two and that would allow me to", "start": 3753.319, "duration": 4.161 }, { "text": "not have to pass in house in this case", "start": 3755.44, "duration": 3.56 }, { "text": "I'm going to continue to always pass in", "start": 3757.48, "duration": 3.319 }, { "text": "name and house but you could make things", "start": 3759.0, "duration": 3.96 }, { "text": "optional and yes to your second question", "start": 3760.799, "duration": 4.201 }, { "text": "if you wanted to have your own error", "start": 3762.96, "duration": 4.359 }, { "text": "message like an Eric error you could", "start": 3765.0, "duration": 5.319 }, { "text": "actually create your own Eric error", "start": 3767.319, "duration": 4.921 }, { "text": "exception and we'll see in a little bit", "start": 3770.319, "duration": 3.48 }, { "text": "that there's actually a whole Suite of", "start": 3772.24, "duration": 3.359 }, { "text": "exceptions that exist and you too can", "start": 3773.799, "duration": 5.32 }, { "text": "invent those as well let me propose", "start": 3775.599, "duration": 6.281 }, { "text": "though that we now introduce one other", "start": 3779.119, "duration": 5.561 }, { "text": "aspect of this whereby we try printing", "start": 3781.88, "duration": 4.679 }, { "text": "out what a student looks like at the", "start": 3784.68, "duration": 3.599 }, { "text": "moment if I scroll back down to my main", "start": 3786.559, "duration": 3.28 }, { "text": "function I'm still printing the", "start": 3788.279, "duration": 3.481 }, { "text": "student's name and house very manually", "start": 3789.839, "duration": 3.921 }, { "text": "I'm going inside of the object doing", "start": 3791.76, "duration": 3.92 }, { "text": "student. name and I'm going inside of", "start": 3793.76, "duration": 3.599 }, { "text": "the object again and getting student.", "start": 3795.68, "duration": 4.159 }, { "text": "house just to see where uh the student", "start": 3797.359, "duration": 4.68 }, { "text": "is from but wouldn't it be nice if I", "start": 3799.839, "duration": 4.081 }, { "text": "could just print the student like I've", "start": 3802.039, "duration": 4.681 }, { "text": "been PR printing for weeks any int or", "start": 3803.92, "duration": 5.679 }, { "text": "float or stir or any other data type", "start": 3806.72, "duration": 4.319 }, { "text": "well let's see what happens if I just", "start": 3809.599, "duration": 3.48 }, { "text": "try printing the student instead of", "start": 3811.039, "duration": 3.641 }, { "text": "manually going inside and trying to", "start": 3813.079, "duration": 3.681 }, { "text": "create that sentence myself well in my", "start": 3814.68, "duration": 3.359 }, { "text": "terminal window let me go ahead and run", "start": 3816.76, "duration": 3.88 }, { "text": "python of student. again let me type in", "start": 3818.039, "duration": 4.961 }, { "text": "Harry let me type in Gryffindor and we", "start": 3820.64, "duration": 5.28 }, { "text": "voila Harry whoa okay main student", "start": 3823.0, "duration": 6.48 }, { "text": "object at o x102 733", "start": 3825.92, "duration": 6.56 }, { "text": "e80 well what is going on well if you", "start": 3829.48, "duration": 4.52 }, { "text": "were to run the same code you might", "start": 3832.48, "duration": 3.079 }, { "text": "actually see something different on your", "start": 3834.0, "duration": 3.44 }, { "text": "computer in terms of that number but", "start": 3835.559, "duration": 3.601 }, { "text": "what you're really seeing is the", "start": 3837.44, "duration": 4.839 }, { "text": "underlying representation as a string of", "start": 3839.16, "duration": 5.04 }, { "text": "this specific object in particular", "start": 3842.279, "duration": 3.681 }, { "text": "you're seeing where in the computer's", "start": 3844.2, "duration": 6.2 }, { "text": "memory it is this number o x102 733 e80", "start": 3845.96, "duration": 6.079 }, { "text": "refers to essentially a specific", "start": 3850.4, "duration": 4.199 }, { "text": "location in the computer's memory or Ram", "start": 3852.039, "duration": 4.441 }, { "text": "that's not really that interesting for", "start": 3854.599, "duration": 4.561 }, { "text": "me or you or generally speaking", "start": 3856.48, "duration": 4.68 }, { "text": "programmers but it's just a default way", "start": 3859.16, "duration": 5.52 }, { "text": "of describing via print what this thing", "start": 3861.16, "duration": 7.08 }, { "text": "uh is but I can override this as well it", "start": 3864.68, "duration": 5.879 }, { "text": "turns out that there are other special", "start": 3868.24, "duration": 4.039 }, { "text": "methods in Python when it comes to", "start": 3870.559, "duration": 4.0 }, { "text": "classes not just underscore underscore", "start": 3872.279, "duration": 4.241 }, { "text": "in it underscore underscore But", "start": 3874.559, "duration": 3.72 }, { "text": "continuing in that same pattern", "start": 3876.52, "duration": 4.72 }, { "text": "underscore underscore stir underscore", "start": 3878.279, "duration": 5.04 }, { "text": "underscore so this too is a special", "start": 3881.24, "duration": 4.76 }, { "text": "method that if you define it inside of", "start": 3883.319, "duration": 5.24 }, { "text": "your class python will just", "start": 3886.0, "duration": 5.4 }, { "text": "automatically call this function for you", "start": 3888.559, "duration": 5.921 }, { "text": "anytime some other function wants to see", "start": 3891.4, "duration": 6.04 }, { "text": "your object as a string print wants to", "start": 3894.48, "duration": 5.559 }, { "text": "see your F your object as a string but", "start": 3897.44, "duration": 4.399 }, { "text": "by default if you don't have this method", "start": 3900.039, "duration": 3.121 }, { "text": "defined in your class it's going to", "start": 3901.839, "duration": 3.48 }, { "text": "print out that very ugly esoteric", "start": 3903.16, "duration": 4.199 }, { "text": "Incarnation thereof where it says main.", "start": 3905.319, "duration": 5.401 }, { "text": "student object at Ox dot dot dot well", "start": 3907.359, "duration": 5.281 }, { "text": "how can I then Define my own stir", "start": 3910.72, "duration": 4.559 }, { "text": "function well here back in VSS code let", "start": 3912.64, "duration": 5.08 }, { "text": "me propose that I go in and Define not", "start": 3915.279, "duration": 5.881 }, { "text": "just underscore underscore uh in it but", "start": 3917.72, "duration": 5.28 }, { "text": "let me Define a second function in this", "start": 3921.16, "duration": 5.879 }, { "text": "class here as follows decore uncore stir", "start": 3923.0, "duration": 6.0 }, { "text": "underscore underscore there are indeed", "start": 3927.039, "duration": 3.681 }, { "text": "two even though the font in VSS code is", "start": 3929.0, "duration": 3.52 }, { "text": "putting the two underscore so close it", "start": 3930.72, "duration": 3.599 }, { "text": "just looks like a longer underscore", "start": 3932.52, "duration": 3.319 }, { "text": "there are indeed two there on the left", "start": 3934.319, "duration": 3.681 }, { "text": "and the right just like for in it this", "start": 3935.839, "duration": 5.121 }, { "text": "one only takes one argument that by", "start": 3938.0, "duration": 4.96 }, { "text": "convention is always called self so that", "start": 3940.96, "duration": 4.68 }, { "text": "you have access to it and then indented", "start": 3942.96, "duration": 5.159 }, { "text": "below that after a colon I'm going to go", "start": 3945.64, "duration": 4.8 }, { "text": "ahead and create a format string and", "start": 3948.119, "duration": 5.2 }, { "text": "return it so let me go ahead and return", "start": 3950.44, "duration": 4.399 }, { "text": "how about something gener generic first", "start": 3953.319, "duration": 3.72 }, { "text": "like a student so I'm not going to", "start": 3954.839, "duration": 4.28 }, { "text": "bother even trying to figure out what", "start": 3957.039, "duration": 3.681 }, { "text": "this Student's name or house is I'm just", "start": 3959.119, "duration": 4.16 }, { "text": "going to always return a student let me", "start": 3960.72, "duration": 5.399 }, { "text": "go back now to my earlier code which has", "start": 3963.279, "duration": 6.04 }, { "text": "print student on line 16 Let Me Clear My", "start": 3966.119, "duration": 5.48 }, { "text": "terminal window and rerun python of", "start": 3969.319, "duration": 4.881 }, { "text": "studenty enter type in Harry type in", "start": 3971.599, "duration": 4.68 }, { "text": "Gryffindor last time I saw that very", "start": 3974.2, "duration": 4.159 }, { "text": "cryptic output this time I see more", "start": 3976.279, "duration": 4.84 }, { "text": "generically a student you know more", "start": 3978.359, "duration": 5.161 }, { "text": "readable but not very enlightening which", "start": 3981.119, "duration": 6.44 }, { "text": "student is this well notice that the uh", "start": 3983.52, "duration": 6.92 }, { "text": "double underscore stir method takes in", "start": 3987.559, "duration": 5.72 }, { "text": "this self argument by default it's just", "start": 3990.44, "duration": 5.679 }, { "text": "the way the python authors designed this", "start": 3993.279, "duration": 5.481 }, { "text": "method it will always be passed a", "start": 3996.119, "duration": 5.68 }, { "text": "reference to the current student object", "start": 3998.76, "duration": 5.079 }, { "text": "what do I mean by that when this line of", "start": 4001.799, "duration": 5.0 }, { "text": "code on line six is called print because", "start": 4003.839, "duration": 4.96 }, { "text": "it's hoping it's going to get a string", "start": 4006.799, "duration": 4.161 }, { "text": "is going to trigger the underscore", "start": 4008.799, "duration": 4.76 }, { "text": "uncore stir underscore uncore method to", "start": 4010.96, "duration": 3.72 }, { "text": "be called", "start": 4013.559, "duration": 3.121 }, { "text": "and python for you automatically is", "start": 4014.68, "duration": 4.0 }, { "text": "going to pass into that method a", "start": 4016.68, "duration": 4.28 }, { "text": "reference to the object that's trying to", "start": 4018.68, "duration": 5.04 }, { "text": "be printed so that you the programmer", "start": 4020.96, "duration": 4.839 }, { "text": "can do something like this here's an F", "start": 4023.72, "duration": 4.319 }, { "text": "string with double quotes as usual I'm", "start": 4025.799, "duration": 4.081 }, { "text": "going to use some curly braces and say", "start": 4028.039, "duration": 6.441 }, { "text": "print out self. name from self. house so", "start": 4029.88, "duration": 6.64 }, { "text": "there's nothing new in what I've just", "start": 4034.48, "duration": 4.92 }, { "text": "done it's just an F string an F on the", "start": 4036.52, "duration": 4.759 }, { "text": "beginning two double quotes a couple of", "start": 4039.4, "duration": 4.56 }, { "text": "pairs of curly braces but because Auto", "start": 4041.279, "duration": 6.28 }, { "text": "automatically this stir method gets past", "start": 4043.96, "duration": 5.76 }, { "text": "self so to speak a reference to the", "start": 4047.559, "duration": 4.441 }, { "text": "current object I can go inside of that", "start": 4049.72, "duration": 3.96 }, { "text": "object and grab the name I can go inside", "start": 4052.0, "duration": 4.52 }, { "text": "that object again and grab the house so", "start": 4053.68, "duration": 5.2 }, { "text": "now when I go back to my terminal window", "start": 4056.52, "duration": 4.599 }, { "text": "previously it just printed out a student", "start": 4058.88, "duration": 4.8 }, { "text": "but now if I run python of student.", "start": 4061.119, "duration": 5.321 }, { "text": "enter type in Harry type in Gryffindor", "start": 4063.68, "duration": 5.28 }, { "text": "and one more time hit enter Harry is", "start": 4066.44, "duration": 5.159 }, { "text": "again from Gryffindor but if I run this", "start": 4068.96, "duration": 4.92 }, { "text": "yet again let's for instance do Drake", "start": 4071.599, "duration": 6.2 }, { "text": "Draco is from Slytherin enter Draco is", "start": 4073.88, "duration": 6.159 }, { "text": "from Slytherin now it's customized to", "start": 4077.799, "duration": 5.641 }, { "text": "the specific object that we're trying to", "start": 4080.039, "duration": 8.32 }, { "text": "print questions on this function here", "start": 4083.44, "duration": 8.72 }, { "text": "this thunder stir method is there", "start": 4088.359, "duration": 6.121 }, { "text": "anything else that the uncore uncore", "start": 4092.16, "duration": 5.119 }, { "text": "stir method can do um the other question", "start": 4094.48, "duration": 4.08 }, { "text": "is what's the difference between stir", "start": 4097.279, "duration": 3.56 }, { "text": "and repper a good question so there are", "start": 4098.56, "duration": 5.4 }, { "text": "many other methods that come with python", "start": 4100.839, "duration": 4.681 }, { "text": "classes that start with underscore", "start": 4103.96, "duration": 2.839 }, { "text": "underscore we're just scratching the", "start": 4105.52, "duration": 2.639 }, { "text": "surface and we'll pretty much Focus", "start": 4106.799, "duration": 3.081 }, { "text": "primarily on these but yes there are", "start": 4108.159, "duration": 3.241 }, { "text": "many others and we'll see at least one", "start": 4109.88, "duration": 3.879 }, { "text": "other in just a little bit there is an", "start": 4111.4, "duration": 4.72 }, { "text": "among the others is indeed one called uh", "start": 4113.759, "duration": 4.841 }, { "text": "repper which is a representation of the", "start": 4116.12, "duration": 4.76 }, { "text": "Python object generally speaking the", "start": 4118.6, "duration": 5.84 }, { "text": "underscore uncore rcore uncore method is", "start": 4120.88, "duration": 5.319 }, { "text": "meant for developers eyes it typically", "start": 4124.44, "duration": 4.0 }, { "text": "has more information than Harry from", "start": 4126.199, "duration": 4.48 }, { "text": "Gryffindor it would also say what type", "start": 4128.44, "duration": 5.0 }, { "text": "of object it is like a student capital S", "start": 4130.679, "duration": 4.48 }, { "text": "whereas underscore uncore stir", "start": 4133.44, "duration": 3.52 }, { "text": "underscore uncore is generally meant for", "start": 4135.159, "duration": 4.16 }, { "text": "users uh the users of the program and", "start": 4136.96, "duration": 4.359 }, { "text": "it's meant to be even more user friendly", "start": 4139.319, "duration": 4.0 }, { "text": "but both of those can be overridden as", "start": 4141.319, "duration": 4.4 }, { "text": "you see fit well let me propose now that", "start": 4143.319, "duration": 4.121 }, { "text": "we pick up where we've left off on", "start": 4145.719, "duration": 3.52 }, { "text": "student and just add even more", "start": 4147.44, "duration": 3.879 }, { "text": "functionality but not just these special", "start": 4149.239, "duration": 4.361 }, { "text": "methods like double underscore init and", "start": 4151.319, "duration": 4.281 }, { "text": "double underscore stir like let's create", "start": 4153.6, "duration": 4.159 }, { "text": "our own methods because there in lies", "start": 4155.6, "duration": 3.88 }, { "text": "the real power and flexibility of", "start": 4157.759, "duration": 4.0 }, { "text": "classes if you and I as the programmers", "start": 4159.48, "duration": 4.52 }, { "text": "can invent new functionality that", "start": 4161.759, "duration": 4.52 }, { "text": "specific to students for instance uh", "start": 4164.0, "duration": 4.48 }, { "text": "students at Hogwarts over the time in in", "start": 4166.279, "duration": 4.361 }, { "text": "school learn how to cast a certain type", "start": 4168.48, "duration": 4.319 }, { "text": "of spell so when they say expecto", "start": 4170.64, "duration": 4.039 }, { "text": "patronum something comes out of their", "start": 4172.799, "duration": 3.681 }, { "text": "wand that typically resembles an animal", "start": 4174.679, "duration": 3.16 }, { "text": "or something like that it's a special", "start": 4176.48, "duration": 2.759 }, { "text": "spell that they have to practice and", "start": 4177.839, "duration": 4.121 }, { "text": "practice so let's see if we can't store", "start": 4179.239, "duration": 4.44 }, { "text": "not just a student's name and their", "start": 4181.96, "duration": 3.96 }, { "text": "house but also their Patronis what", "start": 4183.679, "duration": 4.52 }, { "text": "actually they conjure when using this", "start": 4185.92, "duration": 3.879 }, { "text": "spell well let me go ahead and clear my", "start": 4188.199, "duration": 4.241 }, { "text": "terminal window and in the top of my", "start": 4189.799, "duration": 6.041 }, { "text": "code here in the in it method of student", "start": 4192.44, "duration": 5.52 }, { "text": "let me go ahead and start expecting a", "start": 4195.84, "duration": 4.319 }, { "text": "third argument in addition to self which", "start": 4197.96, "duration": 4.04 }, { "text": "automatically gets passed in called", "start": 4200.159, "duration": 4.161 }, { "text": "petronis and I'm not going to worry uh", "start": 4202.0, "duration": 4.92 }, { "text": "for now on validating the petronis from", "start": 4204.32, "duration": 4.879 }, { "text": "an official list of valid patronises or", "start": 4206.92, "duration": 4.4 }, { "text": "petroni I'm instead going to go ahead", "start": 4209.199, "duration": 4.881 }, { "text": "and just blindly assign it to self.", "start": 4211.32, "duration": 5.08 }, { "text": "Patronis equals Patronis and we're going", "start": 4214.08, "duration": 4.32 }, { "text": "to let the user type whatever they want", "start": 4216.4, "duration": 4.0 }, { "text": "for now but I could certainly add more", "start": 4218.4, "duration": 4.12 }, { "text": "error checking if I wanted to limit the", "start": 4220.4, "duration": 4.56 }, { "text": "patronises to a specific list of them", "start": 4222.52, "duration": 5.04 }, { "text": "here let me go ahead now and prompt the", "start": 4224.96, "duration": 5.4 }, { "text": "user for this Patronis as by in my get", "start": 4227.56, "duration": 5.159 }, { "text": "student method uh get student function", "start": 4230.36, "duration": 4.24 }, { "text": "defining a variable called petronis or", "start": 4232.719, "duration": 3.761 }, { "text": "anything else prompting the user for", "start": 4234.6, "duration": 4.4 }, { "text": "input for their petronis and now I'm", "start": 4236.48, "duration": 4.6 }, { "text": "going to go ahead and pass in that third", "start": 4239.0, "duration": 5.04 }, { "text": "variable here so again similar in spirit", "start": 4241.08, "duration": 4.96 }, { "text": "to just adding more and more attributes", "start": 4244.04, "duration": 3.44 }, { "text": "to the class I'm going to pass in all", "start": 4246.04, "duration": 3.4 }, { "text": "three of these values instead of just", "start": 4247.48, "duration": 3.48 }, { "text": "two I'm not going to do anything", "start": 4249.44, "duration": 3.04 }, { "text": "interesting with that value yet but just", "start": 4250.96, "duration": 3.36 }, { "text": "to make sure I haven't made things worse", "start": 4252.48, "duration": 4.44 }, { "text": "by breaking my code let me run python of", "start": 4254.32, "duration": 5.28 }, { "text": "studenty I'll type in Harry I'll type in", "start": 4256.92, "duration": 4.68 }, { "text": "Gryffindor and it turns out his Patronis", "start": 4259.6, "duration": 4.92 }, { "text": "was a stag and hit enter I haven't seen", "start": 4261.6, "duration": 4.48 }, { "text": "what his Patronis is in my output", "start": 4264.52, "duration": 3.8 }, { "text": "because I didn't change my stir method", "start": 4266.08, "duration": 4.079 }, { "text": "yet but at least I don't have any syntax", "start": 4268.32, "duration": 3.8 }, { "text": "error so at least I've not made anything", "start": 4270.159, "duration": 5.241 }, { "text": "worse but suppose now I want to have", "start": 4272.12, "duration": 5.0 }, { "text": "functionality not just for initializing", "start": 4275.4, "duration": 4.72 }, { "text": "a student and printing out a student if", "start": 4277.12, "duration": 5.599 }, { "text": "my class is really meant to be a student", "start": 4280.12, "duration": 4.64 }, { "text": "what I can do is not just remember", "start": 4282.719, "duration": 4.761 }, { "text": "information about data about students", "start": 4284.76, "duration": 5.2 }, { "text": "what's powerful about classes unlike", "start": 4287.48, "duration": 5.28 }, { "text": "dictionaries alone is that classes can", "start": 4289.96, "duration": 5.68 }, { "text": "have not just variables or instance", "start": 4292.76, "duration": 4.72 }, { "text": "variables so to speak those attributes", "start": 4295.64, "duration": 4.16 }, { "text": "we keep creating they can also have", "start": 4297.48, "duration": 5.759 }, { "text": "functions built in AKA methods when a", "start": 4299.8, "duration": 5.28 }, { "text": "function is inside of a class it's", "start": 4303.239, "duration": 3.721 }, { "text": "called a method but it's still just a", "start": 4305.08, "duration": 4.119 }, { "text": "function at this point we've seen two", "start": 4306.96, "duration": 5.12 }, { "text": "functions already two methods called uh", "start": 4309.199, "duration": 4.401 }, { "text": "double underscore init and double", "start": 4312.08, "duration": 3.92 }, { "text": "underscore stir but those are special", "start": 4313.6, "duration": 4.639 }, { "text": "methods and that they just work if you", "start": 4316.0, "duration": 4.08 }, { "text": "define them python calls them", "start": 4318.239, "duration": 3.841 }, { "text": "automatically for you but what if you", "start": 4320.08, "duration": 4.0 }, { "text": "wanted to create more functionality for", "start": 4322.08, "duration": 4.28 }, { "text": "a student so that your class really", "start": 4324.08, "duration": 4.36 }, { "text": "represents this real world or maybe", "start": 4326.36, "duration": 4.68 }, { "text": "fantasy world notion of a student where", "start": 4328.44, "duration": 4.759 }, { "text": "students not only have names and houses", "start": 4331.04, "duration": 4.44 }, { "text": "and patronises they also have", "start": 4333.199, "duration": 4.841 }, { "text": "functionality they have actions they can", "start": 4335.48, "duration": 6.199 }, { "text": "perform like casting a charm a spell", "start": 4338.04, "duration": 6.4 }, { "text": "magically could we implement therefore a", "start": 4341.679, "duration": 5.761 }, { "text": "function called charm that actually uh", "start": 4344.44, "duration": 5.92 }, { "text": "uses uh their magical knowledge well", "start": 4347.44, "duration": 4.799 }, { "text": "let's go ahead and Define our very own", "start": 4350.36, "duration": 3.76 }, { "text": "function as follows Let Me Clear My", "start": 4352.239, "duration": 4.121 }, { "text": "terminal window scroll back up to my", "start": 4354.12, "duration": 4.84 }, { "text": "student class and instead of creating", "start": 4356.36, "duration": 4.68 }, { "text": "yet another function that's special with", "start": 4358.96, "duration": 4.279 }, { "text": "double underscores I'm going to invent", "start": 4361.04, "duration": 5.199 }, { "text": "my own function or method inside of this", "start": 4363.239, "duration": 5.721 }, { "text": "class I want to give uh Harry and", "start": 4366.239, "duration": 4.641 }, { "text": "Hermione and and all of the other", "start": 4368.96, "duration": 4.56 }, { "text": "students the ability to cast charms so", "start": 4370.88, "duration": 4.0 }, { "text": "I'm going to define a function that I", "start": 4373.52, "duration": 3.56 }, { "text": "can completely on my own called charm", "start": 4374.88, "duration": 3.2 }, { "text": "though I could call this function", "start": 4377.08, "duration": 3.0 }, { "text": "anything I want but because it's a", "start": 4378.08, "duration": 4.44 }, { "text": "method inside of a class the convention", "start": 4380.08, "duration": 3.88 }, { "text": "is that it's always going to take at", "start": 4382.52, "duration": 4.28 }, { "text": "least one argument called self by", "start": 4383.96, "duration": 5.08 }, { "text": "convention so that you have access to", "start": 4386.8, "duration": 4.8 }, { "text": "the current object even if you don't", "start": 4389.04, "duration": 4.599 }, { "text": "plan to use it per se all right let me", "start": 4391.6, "duration": 3.599 }, { "text": "go ahead and propose that we Implement", "start": 4393.639, "duration": 4.121 }, { "text": "charm in such a way that the method", "start": 4395.199, "duration": 5.44 }, { "text": "returns an emoji that's appropriate for", "start": 4397.76, "duration": 5.68 }, { "text": "each student's Patronis all right how to", "start": 4400.639, "duration": 4.56 }, { "text": "implement this well inside of the charm", "start": 4403.44, "duration": 4.759 }, { "text": "method let's go ahead and match on self.", "start": 4405.199, "duration": 5.201 }, { "text": "Patronis which is the instance variable", "start": 4408.199, "duration": 4.04 }, { "text": "containing a string that represents each", "start": 4410.4, "duration": 4.36 }, { "text": "student's petronis and in the case that", "start": 4412.239, "duration": 5.241 }, { "text": "it matches a stag for instance for Harry", "start": 4414.76, "duration": 4.36 }, { "text": "let's go ahead and return maybe the", "start": 4417.48, "duration": 5.04 }, { "text": "closest Emoji this horse here how about", "start": 4419.12, "duration": 6.2 }, { "text": "in the case of an otter well in that", "start": 4422.52, "duration": 6.199 }, { "text": "case let's go ahead and return oh maybe", "start": 4425.32, "duration": 5.08 }, { "text": "the closest match to the otter which", "start": 4428.719, "duration": 4.641 }, { "text": "might be this Emoji here and let's see", "start": 4430.4, "duration": 6.0 }, { "text": "in the case of a for for Ron rather than", "start": 4433.36, "duration": 7.24 }, { "text": "Hermione a Jack Russell Terrier let's go", "start": 4436.4, "duration": 6.88 }, { "text": "ahead and return how about don't have as", "start": 4440.6, "duration": 4.84 }, { "text": "many options here why don't we go ahead", "start": 4443.28, "duration": 4.48 }, { "text": "and return the cutest available dog in", "start": 4445.44, "duration": 7.84 }, { "text": "that case and in the case of no Patronis", "start": 4447.76, "duration": 7.36 }, { "text": "recognized as might cover someone like", "start": 4453.28, "duration": 3.879 }, { "text": "Draco let's go ahead and use a default", "start": 4455.12, "duration": 4.72 }, { "text": "case using the underscore as in the past", "start": 4457.159, "duration": 4.721 }, { "text": "and let's go ahead and return for this", "start": 4459.84, "duration": 3.52 }, { "text": "oh what should happen if someone doesn't", "start": 4461.88, "duration": 3.6 }, { "text": "have a petronis why don't we just see a", "start": 4463.36, "duration": 4.68 }, { "text": "magical wand that seems to fizzle out as", "start": 4465.48, "duration": 4.759 }, { "text": "in this case all right well now rather", "start": 4468.04, "duration": 3.52 }, { "text": "than just print the student let's go", "start": 4470.239, "duration": 3.361 }, { "text": "about printing their actual petronis so", "start": 4471.56, "duration": 3.92 }, { "text": "I'm going to go down to my main function", "start": 4473.6, "duration": 3.8 }, { "text": "here I'm going to still get a student", "start": 4475.48, "duration": 4.04 }, { "text": "using the get student function but", "start": 4477.4, "duration": 3.839 }, { "text": "rather than print student let's go ahead", "start": 4479.52, "duration": 5.119 }, { "text": "and declare expecto patronum printing", "start": 4481.239, "duration": 6.521 }, { "text": "out just that as pure text and now let's", "start": 4484.639, "duration": 5.0 }, { "text": "go ahead and print out not the student", "start": 4487.76, "duration": 4.84 }, { "text": "but rather the return value of their own", "start": 4489.639, "duration": 5.0 }, { "text": "charm method Method All right so let me", "start": 4492.6, "duration": 3.92 }, { "text": "go back down to my terminal window and", "start": 4494.639, "duration": 5.361 }, { "text": "run python of student. and enter name", "start": 4496.52, "duration": 5.8 }, { "text": "let's start with Harry he lives in", "start": 4500.0, "duration": 5.28 }, { "text": "Gryffindor uh petronis is a stag and", "start": 4502.32, "duration": 6.44 }, { "text": "let's see expecto patronum and of course", "start": 4505.28, "duration": 5.959 }, { "text": "we see the Stag Emoji what about someone", "start": 4508.76, "duration": 4.439 }, { "text": "like Draco who at least in the books", "start": 4511.239, "duration": 4.4 }, { "text": "doesn't have a known Patronis well let's", "start": 4513.199, "duration": 4.201 }, { "text": "go ahead and clear my terminal window", "start": 4515.639, "duration": 4.281 }, { "text": "rerun python of student. py and this", "start": 4517.4, "duration": 5.319 }, { "text": "time let's type in Draco for name", "start": 4519.92, "duration": 5.6 }, { "text": "slyther in for house and Patronis is", "start": 4522.719, "duration": 4.0 }, { "text": "unknown so I'm just going to go ahead", "start": 4525.52, "duration": 4.08 }, { "text": "and hit enter and now expecto patronum", "start": 4526.719, "duration": 6.401 }, { "text": "and just kind of sizzles instead well", "start": 4529.6, "duration": 7.2 }, { "text": "let me propose now that we remove this", "start": 4533.12, "duration": 6.48 }, { "text": "petronis code just to simplify our world", "start": 4536.8, "duration": 4.96 }, { "text": "and focus on some of the other core", "start": 4539.6, "duration": 4.2 }, { "text": "capabilities of classes so at the risk", "start": 4541.76, "duration": 3.6 }, { "text": "of disappointing I'm going to get rid of", "start": 4543.8, "duration": 4.2 }, { "text": "all of these beautiful emoji and charms", "start": 4545.36, "duration": 4.279 }, { "text": "and I'm going to go ahead and stop", "start": 4548.0, "duration": 3.96 }, { "text": "asking the user now for their petronis", "start": 4549.639, "duration": 4.441 }, { "text": "and I'm going to stop passing it into in", "start": 4551.96, "duration": 4.84 }, { "text": "it here and I'm going to stop uh doing", "start": 4554.08, "duration": 5.36 }, { "text": "this here and I'm going to instead just", "start": 4556.8, "duration": 5.8 }, { "text": "go ahead and restore our use of print", "start": 4559.44, "duration": 5.36 }, { "text": "student here and I'm going to go ahead", "start": 4562.6, "duration": 4.52 }, { "text": "and get rid of petronis down here so", "start": 4564.8, "duration": 4.52 }, { "text": "essentially undo all of the fun charms", "start": 4567.12, "duration": 4.36 }, { "text": "we just created so we're now back at the", "start": 4569.32, "duration": 5.879 }, { "text": "point in the story where we have a", "start": 4571.48, "duration": 6.64 }, { "text": "student class with only two methods in", "start": 4575.199, "duration": 5.44 }, { "text": "it and stir the first of those takes of", "start": 4578.12, "duration": 4.24 }, { "text": "course self as the first argument as it", "start": 4580.639, "duration": 4.0 }, { "text": "always will plus two more now name and", "start": 4582.36, "duration": 4.6 }, { "text": "house no more Patronis we're validating", "start": 4584.639, "duration": 4.761 }, { "text": "name up here we're validating house down", "start": 4586.96, "duration": 4.199 }, { "text": "here and then we're assigning name and", "start": 4589.4, "duration": 3.72 }, { "text": "house respectively to two instance", "start": 4591.159, "duration": 4.401 }, { "text": "variables called name and house also but", "start": 4593.12, "duration": 4.72 }, { "text": "we used self to get access to the", "start": 4595.56, "duration": 4.4 }, { "text": "current object to store those values", "start": 4597.84, "duration": 4.319 }, { "text": "therein we then still have our stir", "start": 4599.96, "duration": 4.64 }, { "text": "method here which takes one argument by", "start": 4602.159, "duration": 4.48 }, { "text": "default self and that's it and that", "start": 4604.6, "duration": 3.28 }, { "text": "function is going to be called", "start": 4606.639, "duration": 3.321 }, { "text": "automatically anytime you want to", "start": 4607.88, "duration": 4.68 }, { "text": "convert a student object to a string", "start": 4609.96, "duration": 5.199 }, { "text": "just like print might want to do here so", "start": 4612.56, "duration": 4.079 }, { "text": "let me go ahead and just make sure I", "start": 4615.159, "duration": 2.921 }, { "text": "haven't broken anything let me run", "start": 4616.639, "duration": 4.08 }, { "text": "python of studenty I'll type in Harry", "start": 4618.08, "duration": 5.36 }, { "text": "I'll type in Gryffindor enter okay we're", "start": 4620.719, "duration": 4.721 }, { "text": "back in business gone are the charms and", "start": 4623.44, "duration": 4.08 }, { "text": "patronises but at least I'm back to a", "start": 4625.44, "duration": 4.68 }, { "text": "situation where I have names and houses", "start": 4627.52, "duration": 5.76 }, { "text": "but it turns out at the moment our use", "start": 4630.12, "duration": 6.68 }, { "text": "of classes is not very robust even", "start": 4633.28, "duration": 6.0 }, { "text": "though we have this mechanism very", "start": 4636.8, "duration": 5.32 }, { "text": "cleverly if I may in our init method of", "start": 4639.28, "duration": 5.32 }, { "text": "making sure that validating name and", "start": 4642.12, "duration": 4.96 }, { "text": "house making sure that name is not blank", "start": 4644.6, "duration": 5.039 }, { "text": "and making sure that house is a valid", "start": 4647.08, "duration": 5.639 }, { "text": "house among those four Hogwarts houses", "start": 4649.639, "duration": 5.201 }, { "text": "it turns out that classes will still let", "start": 4652.719, "duration": 4.081 }, { "text": "me get at those attributes those", "start": 4654.84, "duration": 4.359 }, { "text": "so-called instance variables using dot", "start": 4656.8, "duration": 5.16 }, { "text": "notation anyway let me scroll down then", "start": 4659.199, "duration": 4.401 }, { "text": "and try to do this a little", "start": 4661.96, "duration": 4.52 }, { "text": "adversarially suppose that on line 16 I", "start": 4663.6, "duration": 4.92 }, { "text": "go ahead and call get student which", "start": 4666.48, "duration": 4.679 }, { "text": "exists as before and then I store the", "start": 4668.52, "duration": 4.8 }, { "text": "return value in a student variable again", "start": 4671.159, "duration": 5.841 }, { "text": "on line 16 that will ensure that get", "start": 4673.32, "duration": 6.04 }, { "text": "student gets called which calls input", "start": 4677.0, "duration": 5.08 }, { "text": "and input and then it calls the student", "start": 4679.36, "duration": 4.76 }, { "text": "Constructor which invokes automatically", "start": 4682.08, "duration": 4.639 }, { "text": "this init method so by way of how we've", "start": 4684.12, "duration": 5.0 }, { "text": "laid out my code we're going to ensure", "start": 4686.719, "duration": 4.401 }, { "text": "that name is not blank and house is", "start": 4689.12, "duration": 3.84 }, { "text": "definitely one of those four values my", "start": 4691.12, "duration": 4.519 }, { "text": "error correction or error checking is in", "start": 4692.96, "duration": 6.16 }, { "text": "place but if I'm a little adversarial I", "start": 4695.639, "duration": 5.961 }, { "text": "can still circumvent it suppose that", "start": 4699.12, "duration": 4.079 }, { "text": "fine I'm going to you're going to", "start": 4701.6, "duration": 3.0 }, { "text": "require me to type in Harry and", "start": 4703.199, "duration": 3.121 }, { "text": "Gryffindor I'm going to go ahead and", "start": 4704.6, "duration": 3.88 }, { "text": "type in student.h housee equals quote", "start": 4706.32, "duration": 5.44 }, { "text": "unquote number four private drive and", "start": 4708.48, "duration": 4.92 }, { "text": "you're not going to be able to stop me", "start": 4711.76, "duration": 4.36 }, { "text": "why well it turns out with classes and", "start": 4713.4, "duration": 5.08 }, { "text": "objects thereof you and I can still", "start": 4716.12, "duration": 4.4 }, { "text": "access those instance variables using", "start": 4718.48, "duration": 3.88 }, { "text": "this familiar dot notation that's how we", "start": 4720.52, "duration": 3.679 }, { "text": "began the story of classes just setting", "start": 4722.36, "duration": 3.839 }, { "text": "these attributes ourselves but you can", "start": 4724.199, "duration": 4.241 }, { "text": "also read these attributes themselves", "start": 4726.199, "duration": 4.841 }, { "text": "and change them later if you want and", "start": 4728.44, "duration": 5.719 }, { "text": "this will effectively circumvent the if", "start": 4731.04, "duration": 4.72 }, { "text": "condition and the other if condition in", "start": 4734.159, "duration": 4.201 }, { "text": "our init method because that is only", "start": 4735.76, "duration": 5.6 }, { "text": "called when you first create the student", "start": 4738.36, "duration": 5.12 }, { "text": "object there's nothing stopping me at", "start": 4741.36, "duration": 5.24 }, { "text": "the moment from just changing the house", "start": 4743.48, "duration": 6.4 }, { "text": "or the name after so if I now clear my", "start": 4746.6, "duration": 4.88 }, { "text": "terminal window and run python of", "start": 4749.88, "duration": 4.12 }, { "text": "studenty I'll still type in Harry and", "start": 4751.48, "duration": 4.679 }, { "text": "Gryffindor to meet my requirements that", "start": 4754.0, "duration": 4.08 }, { "text": "the house be one of those four but when", "start": 4756.159, "duration": 3.961 }, { "text": "it's printed notice I've still", "start": 4758.08, "duration": 4.92 }, { "text": "overridden it so it seems that while", "start": 4760.12, "duration": 4.64 }, { "text": "classes do allow us a little more", "start": 4763.0, "duration": 4.28 }, { "text": "control over the data we're storing it", "start": 4764.76, "duration": 5.32 }, { "text": "doesn't necessarily prevent the user be", "start": 4767.28, "duration": 5.12 }, { "text": "it or rather the programmer be it myself", "start": 4770.08, "duration": 4.32 }, { "text": "or maybe a colleague from still kind of", "start": 4772.4, "duration": 4.799 }, { "text": "messing things up so here too in the", "start": 4774.4, "duration": 4.56 }, { "text": "spirit of programming a little more", "start": 4777.199, "duration": 3.801 }, { "text": "defensively allow me to introduce", "start": 4778.96, "duration": 6.16 }, { "text": "another feature of python as well namely", "start": 4781.0, "duration": 7.32 }, { "text": "properties so a property is really just", "start": 4785.12, "duration": 5.92 }, { "text": "an attribute that has even more defense", "start": 4788.32, "duration": 4.56 }, { "text": "mechanisms put into place a little", "start": 4791.04, "duration": 4.32 }, { "text": "little more functionality implemented by", "start": 4792.88, "duration": 5.359 }, { "text": "you to prevent programmers like me and", "start": 4795.36, "duration": 4.92 }, { "text": "you from messing things up like these", "start": 4798.239, "duration": 4.161 }, { "text": "attributes so again a property is going", "start": 4800.28, "duration": 3.919 }, { "text": "to be an attribute that you and I just", "start": 4802.4, "duration": 4.72 }, { "text": "have more control over how we just write", "start": 4804.199, "duration": 4.761 }, { "text": "a little more code using some python", "start": 4807.12, "duration": 3.76 }, { "text": "conventions and how we're going to do", "start": 4808.96, "duration": 4.679 }, { "text": "that is going to use in just a moment a", "start": 4810.88, "duration": 5.64 }, { "text": "feature a keyword known as app property", "start": 4813.639, "duration": 4.761 }, { "text": "which is technically a function property", "start": 4816.52, "duration": 3.76 }, { "text": "is a function in Python but we're about", "start": 4818.4, "duration": 4.799 }, { "text": "to see some new at syntax that allows", "start": 4820.28, "duration": 4.8 }, { "text": "you to decorate functions and this too", "start": 4823.199, "duration": 4.081 }, { "text": "is a term of Art in the world of python", "start": 4825.08, "duration": 4.48 }, { "text": "you can have decorators which are", "start": 4827.28, "duration": 4.72 }, { "text": "functions that modify the behavior of", "start": 4829.56, "duration": 4.28 }, { "text": "other functions if you will and we'll", "start": 4832.0, "duration": 3.84 }, { "text": "leave it at that without going too much", "start": 4833.84, "duration": 3.76 }, { "text": "into the weeds and we'll see by example", "start": 4835.84, "duration": 3.319 }, { "text": "how you can use these decorator", "start": 4837.6, "duration": 4.0 }, { "text": "specifically to define properties so let", "start": 4839.159, "duration": 5.04 }, { "text": "me go back to vs code here and let me", "start": 4841.6, "duration": 5.76 }, { "text": "propose that I do this I'm going to go", "start": 4844.199, "duration": 7.96 }, { "text": "ahead and create how about a property", "start": 4847.36, "duration": 9.16 }, { "text": "called how house as follows inside of my", "start": 4852.159, "duration": 7.04 }, { "text": "uh student class I'm going to go ahead", "start": 4856.52, "duration": 4.6 }, { "text": "and below my init method and below my", "start": 4859.199, "duration": 4.081 }, { "text": "stir method I'm going to go ahead and", "start": 4861.12, "duration": 5.039 }, { "text": "Define a function called house that", "start": 4863.28, "duration": 5.16 }, { "text": "takes as it always must one argument at", "start": 4866.159, "duration": 4.56 }, { "text": "least called self and what I'm going to", "start": 4868.44, "duration": 7.239 }, { "text": "do now is return uh self. house so I'm", "start": 4870.719, "duration": 6.761 }, { "text": "just going to define a method called", "start": 4875.679, "duration": 4.801 }, { "text": "House whose sole purpose in life is to", "start": 4877.48, "duration": 5.88 }, { "text": "return the value of house", "start": 4880.48, "duration": 4.96 }, { "text": "but I'm going to Define one other method", "start": 4883.36, "duration": 4.319 }, { "text": "curiously also called house but that's", "start": 4885.44, "duration": 5.32 }, { "text": "going to take into as arguments two", "start": 4887.679, "duration": 6.641 }, { "text": "value self as always and also a value", "start": 4890.76, "duration": 6.12 }, { "text": "called house and I'm going to now do", "start": 4894.32, "duration": 6.04 }, { "text": "this uh I'm going to say self rather I'm", "start": 4896.88, "duration": 7.319 }, { "text": "going to do self. house equals house now", "start": 4900.36, "duration": 5.24 }, { "text": "what have I done well let me just", "start": 4904.199, "duration": 3.601 }, { "text": "temporarily add some comments here in a", "start": 4905.6, "duration": 3.8 }, { "text": "moment we're going to start referring to", "start": 4907.8, "duration": 4.04 }, { "text": "this generally as a getter and down here", "start": 4909.4, "duration": 3.88 }, { "text": "I'm going to refer to to this as a", "start": 4911.84, "duration": 3.24 }, { "text": "Setter and this is terminology you", "start": 4913.28, "duration": 3.399 }, { "text": "frequently see in the world of java if", "start": 4915.08, "duration": 3.0 }, { "text": "some of you have programmed in Java", "start": 4916.679, "duration": 4.201 }, { "text": "before but as the names imply a getter", "start": 4918.08, "duration": 6.24 }, { "text": "is a function for a class that gets some", "start": 4920.88, "duration": 6.96 }, { "text": "attribute a Setter is a function in some", "start": 4924.32, "duration": 6.6 }, { "text": "class that sets some value and now even", "start": 4927.84, "duration": 4.76 }, { "text": "though we're not done and there's a bit", "start": 4930.92, "duration": 3.52 }, { "text": "of a mistake in the code I've already", "start": 4932.6, "duration": 4.0 }, { "text": "written intuitively what we're going to", "start": 4934.44, "duration": 4.759 }, { "text": "do is this we're trying to prevent", "start": 4936.6, "duration": 4.68 }, { "text": "programmers myself included from", "start": 4939.199, "duration": 4.201 }, { "text": "circumventing my error checking that I", "start": 4941.28, "duration": 4.68 }, { "text": "put into place for name and house how", "start": 4943.4, "duration": 4.279 }, { "text": "can I do that well we don't have that", "start": 4945.96, "duration": 3.6 }, { "text": "many building blocks in programming we", "start": 4947.679, "duration": 3.921 }, { "text": "have things like variables for data and", "start": 4949.56, "duration": 4.24 }, { "text": "we have functions for actions well why", "start": 4951.6, "duration": 5.039 }, { "text": "don't we do this why don't we somehow", "start": 4953.8, "duration": 5.439 }, { "text": "require that in order to access an", "start": 4956.639, "duration": 4.801 }, { "text": "attribute you go through some function", "start": 4959.239, "duration": 4.361 }, { "text": "and let's require that in order to set", "start": 4961.44, "duration": 4.0 }, { "text": "some attribute you go through some", "start": 4963.6, "duration": 4.599 }, { "text": "function and conventionally those", "start": 4965.44, "duration": 5.44 }, { "text": "functions are called a getter function", "start": 4968.199, "duration": 5.04 }, { "text": "and a Setter function and why are we", "start": 4970.88, "duration": 4.4 }, { "text": "using functions or in this case methods", "start": 4973.239, "duration": 4.361 }, { "text": "inside of a class well once you have", "start": 4975.28, "duration": 4.16 }, { "text": "functions those are just actions or", "start": 4977.6, "duration": 3.2 }, { "text": "verbs that you and I can create", "start": 4979.44, "duration": 3.32 }, { "text": "ourselves we can put any error", "start": 4980.8, "duration": 4.359 }, { "text": "correction I want in these functions", "start": 4982.76, "duration": 3.84 }, { "text": "because it's code that's going to get", "start": 4985.159, "duration": 4.601 }, { "text": "executed top to bottom so how can I now", "start": 4986.6, "duration": 7.079 }, { "text": "prevent the user from setting the house", "start": 4989.76, "duration": 6.919 }, { "text": "to an invalid value let me borrow some", "start": 4993.679, "duration": 5.841 }, { "text": "logic from before rather than blindly do", "start": 4996.679, "duration": 5.96 }, { "text": "this just set self. housee equal to that", "start": 4999.52, "duration": 5.159 }, { "text": "house value that's passed in let's add", "start": 5002.639, "duration": 4.841 }, { "text": "our error checking there so if house is", "start": 5004.679, "duration": 6.56 }, { "text": "not in the following list of Gryffindor", "start": 5007.48, "duration": 4.96 }, { "text": "or", "start": 5011.239, "duration": 7.161 }, { "text": "Hufflepuff or slyther or Ravenclaw or", "start": 5012.44, "duration": 8.759 }, { "text": "Slytherin just as before let's go ahead", "start": 5018.4, "duration": 5.16 }, { "text": "and raise a value error just to signify", "start": 5021.199, "duration": 4.081 }, { "text": "that uhuh something has gone wrong I'll", "start": 5023.56, "duration": 3.96 }, { "text": "be more explicit I'll include a message", "start": 5025.28, "duration": 5.359 }, { "text": "like invalid house quote unquote", "start": 5027.52, "duration": 5.4 }, { "text": "otherwise I'm going to proceed on now", "start": 5030.639, "duration": 5.6 }, { "text": "line 21 to set self. house to house so", "start": 5032.92, "duration": 5.719 }, { "text": "I've just copied if you will or retyped", "start": 5036.239, "duration": 4.241 }, { "text": "my error checking inside of this", "start": 5038.639, "duration": 4.441 }, { "text": "so-called Setter function now why have I", "start": 5040.48, "duration": 5.28 }, { "text": "done that well to be clear whenever the", "start": 5043.08, "duration": 5.24 }, { "text": "user or the programmer writes code like", "start": 5045.76, "duration": 6.479 }, { "text": "this student.h housee equals what's", "start": 5048.32, "duration": 7.2 }, { "text": "about to happen magically is python will", "start": 5052.239, "duration": 4.96 }, { "text": "not just let the programmer access", "start": 5055.52, "duration": 4.24 }, { "text": "student.h house directly that attribute", "start": 5057.199, "duration": 5.721 }, { "text": "that instance variable AKA self. housee", "start": 5059.76, "duration": 5.439 }, { "text": "it's instead going to magically", "start": 5062.92, "duration": 5.04 }, { "text": "automatically call this Setter function", "start": 5065.199, "duration": 5.48 }, { "text": "for me how does python not to do that", "start": 5067.96, "duration": 4.92 }, { "text": "well if it sees that on the left hand", "start": 5070.679, "duration": 6.081 }, { "text": "side there is self. house where house is", "start": 5072.88, "duration": 7.44 }, { "text": "the name of the getter or Setter and", "start": 5076.76, "duration": 5.76 }, { "text": "then it sees an equal sign indicating", "start": 5080.32, "duration": 4.16 }, { "text": "assignment that's just enough of a", "start": 5082.52, "duration": 3.679 }, { "text": "visual clue to say wait a minute I'm not", "start": 5084.48, "duration": 3.84 }, { "text": "going to let you access that attribute", "start": 5086.199, "duration": 5.04 }, { "text": "directly I'm going to use the setter", "start": 5088.32, "duration": 4.879 }, { "text": "instead why because the equal sign means", "start": 5091.239, "duration": 3.681 }, { "text": "I'm trying to set I'm trying to assign a", "start": 5093.199, "duration": 4.121 }, { "text": "value from right to left into that", "start": 5094.92, "duration": 4.52 }, { "text": "attribute so what Python's going to do", "start": 5097.32, "duration": 4.359 }, { "text": "automatically is call this function for", "start": 5099.44, "duration": 4.52 }, { "text": "me and that's amazing because now I can", "start": 5101.679, "duration": 5.361 }, { "text": "execute code and algorithm to check do I", "start": 5103.96, "duration": 6.12 }, { "text": "want to let the user the programmer set", "start": 5107.04, "duration": 5.8 }, { "text": "that attribute to that value if not I'm", "start": 5110.08, "duration": 4.2 }, { "text": "going to raise a value error and you're", "start": 5112.84, "duration": 4.0 }, { "text": "just not going to be able to do it if so", "start": 5114.28, "duration": 5.04 }, { "text": "fine I'll go ahead and set it for you", "start": 5116.84, "duration": 4.12 }, { "text": "but in order to do this we need a little", "start": 5119.32, "duration": 3.28 }, { "text": "more syntax and I'm going to get rid of", "start": 5120.96, "duration": 3.44 }, { "text": "my comment and I'm going to use that", "start": 5122.6, "duration": 4.519 }, { "text": "decorator I need to tell python to treat", "start": 5124.4, "duration": 5.6 }, { "text": "this method as a getter and then the", "start": 5127.119, "duration": 4.401 }, { "text": "Syntax for the setter is a little", "start": 5130.0, "duration": 4.639 }, { "text": "different you now say house. Setter I", "start": 5131.52, "duration": 5.199 }, { "text": "wish one was getter and the other was", "start": 5134.639, "duration": 4.04 }, { "text": "Setter that's not the way they designed", "start": 5136.719, "duration": 4.52 }, { "text": "it when you want to define a getter you", "start": 5138.679, "duration": 5.641 }, { "text": "just say at property above the function", "start": 5141.239, "duration": 6.241 }, { "text": "and you name the function exactly like", "start": 5144.32, "duration": 4.879 }, { "text": "you would like the property to be called", "start": 5147.48, "duration": 5.0 }, { "text": "quote unquote house once you do that you", "start": 5149.199, "duration": 5.321 }, { "text": "can now use a new decorator that's sort", "start": 5152.48, "duration": 4.12 }, { "text": "of automatically created for you called", "start": 5154.52, "duration": 4.36 }, { "text": "at house because I called it house and", "start": 5156.6, "duration": 4.84 }, { "text": "then you literally say at house. Setter", "start": 5158.88, "duration": 5.52 }, { "text": "and this whole line on line 17 is a clue", "start": 5161.44, "duration": 5.679 }, { "text": "to python that here comes a function", "start": 5164.4, "duration": 5.319 }, { "text": "whose name is identical but notice that", "start": 5167.119, "duration": 4.721 }, { "text": "it takes two arguments both self so you", "start": 5169.719, "duration": 3.52 }, { "text": "have access to the contents of the", "start": 5171.84, "duration": 3.359 }, { "text": "object and house which is just going to", "start": 5173.239, "duration": 4.48 }, { "text": "be a stir that comes from the programmer", "start": 5175.199, "duration": 5.561 }, { "text": "from like the human input return value", "start": 5177.719, "duration": 6.201 }, { "text": "so that you can set that value as well", "start": 5180.76, "duration": 5.919 }, { "text": "but there's one fix I need to make now", "start": 5183.92, "duration": 5.16 }, { "text": "here everything else I think is still", "start": 5186.679, "duration": 6.121 }, { "text": "good however watch this I no longer need", "start": 5189.08, "duration": 8.0 }, { "text": "this error check here why because if I", "start": 5192.8, "duration": 6.76 }, { "text": "scroll back down to my code here I", "start": 5197.08, "duration": 5.88 }, { "text": "claimed a moment ago that code like this", "start": 5199.56, "duration": 6.76 }, { "text": "with uh student.h house equals is going", "start": 5202.96, "duration": 5.44 }, { "text": "to automatically get python to call my", "start": 5206.32, "duration": 5.879 }, { "text": "Setter for me guess what even up here in", "start": 5208.4, "duration": 6.839 }, { "text": "in my init method calling self. housee", "start": 5212.199, "duration": 6.281 }, { "text": "equals is also going to call my Setter", "start": 5215.239, "duration": 6.041 }, { "text": "method which is amazing because now I", "start": 5218.48, "duration": 5.639 }, { "text": "can keep all of my error checking in one", "start": 5221.28, "duration": 5.879 }, { "text": "place in the setter and it will now get", "start": 5224.119, "duration": 5.52 }, { "text": "called either when I create the object", "start": 5227.159, "duration": 5.441 }, { "text": "for the first time because of in it or", "start": 5229.639, "duration": 5.241 }, { "text": "even if the you the programmer tries to", "start": 5232.6, "duration": 5.24 }, { "text": "circumvent that init method and change", "start": 5234.88, "duration": 4.88 }, { "text": "the value of this attribute my Setter", "start": 5237.84, "duration": 4.48 }, { "text": "will also get called my Setter will get", "start": 5239.76, "duration": 6.359 }, { "text": "called anytime I access. house but", "start": 5242.32, "duration": 6.76 }, { "text": "there's one fix I need to make", "start": 5246.119, "duration": 7.0 }, { "text": "unfortunately I have collided names", "start": 5249.08, "duration": 7.36 }, { "text": "right now if we go up here on line five", "start": 5253.119, "duration": 5.56 }, { "text": "this is an instance variable it's a", "start": 5256.44, "duration": 4.64 }, { "text": "string inside of myself inside of the", "start": 5258.679, "duration": 4.601 }, { "text": "current student object called name and", "start": 5261.08, "duration": 5.0 }, { "text": "this is another instance variable called", "start": 5263.28, "duration": 5.32 }, { "text": "House unfortunately if I have an", "start": 5266.08, "duration": 5.28 }, { "text": "instance variable called name and house", "start": 5268.6, "duration": 5.48 }, { "text": "I cannot also have functions called", "start": 5271.36, "duration": 4.72 }, { "text": "house they're going to collide you got", "start": 5274.08, "duration": 4.24 }, { "text": "to decide do you want the variable to be", "start": 5276.08, "duration": 4.48 }, { "text": "called house or do you want the function", "start": 5278.32, "duration": 4.2 }, { "text": "to be called House unfortunately you", "start": 5280.56, "duration": 3.559 }, { "text": "can't have both because now Python's", "start": 5282.52, "duration": 3.679 }, { "text": "going to confuse one for the other so", "start": 5284.119, "duration": 4.481 }, { "text": "the conventional fix for this is to do", "start": 5286.199, "duration": 6.281 }, { "text": "this to have the setter not store the", "start": 5288.6, "duration": 6.599 }, { "text": "value that's passed in in self. house", "start": 5292.48, "duration": 4.84 }, { "text": "but to use an almost identical name but", "start": 5295.199, "duration": 4.201 }, { "text": "to use a little indicator that you means", "start": 5297.32, "duration": 4.04 }, { "text": "you know you're doing this correctly you", "start": 5299.4, "duration": 4.16 }, { "text": "typically by invention put an underscore", "start": 5301.36, "duration": 5.72 }, { "text": "in front of the instance variable's name", "start": 5303.56, "duration": 5.2 }, { "text": "and when you return it up here you", "start": 5307.08, "duration": 4.96 }, { "text": "similarly put an underscore so now", "start": 5308.76, "duration": 5.64 }, { "text": "technically my instance variable is", "start": 5312.04, "duration": 6.84 }, { "text": "called underscore house but my property", "start": 5314.4, "duration": 7.239 }, { "text": "which is a fancier attribute if you will", "start": 5318.88, "duration": 6.6 }, { "text": "is called house alone huge amount of", "start": 5321.639, "duration": 6.361 }, { "text": "syntax I know but it's a very powerful", "start": 5325.48, "duration": 4.719 }, { "text": "feature and again this is why you can", "start": 5328.0, "duration": 4.4 }, { "text": "graduate from dictionaries alone and", "start": 5330.199, "duration": 4.361 }, { "text": "have so much more functionality at your", "start": 5332.4, "duration": 4.0 }, { "text": "disposal let me go ahead and clear my", "start": 5334.56, "duration": 3.32 }, { "text": "terminal window and run python of", "start": 5336.4, "duration": 4.6 }, { "text": "student. enter name all right let's go", "start": 5337.88, "duration": 5.279 }, { "text": "ahead and type in Harry let's go ahead", "start": 5341.0, "duration": 4.159 }, { "text": "and type in Gryffindor crossing my", "start": 5343.159, "duration": 5.321 }, { "text": "fingers as always and now look invalid", "start": 5345.159, "duration": 5.921 }, { "text": "house this is a good thing why because", "start": 5348.48, "duration": 6.159 }, { "text": "notice in my main function I'm still", "start": 5351.08, "duration": 6.76 }, { "text": "trying maliciously if you will to change", "start": 5354.639, "duration": 5.6 }, { "text": "Harry's house to not be one of the four", "start": 5357.84, "duration": 3.799 }, { "text": "valid ones I'm trying to change it to", "start": 5360.239, "duration": 3.4 }, { "text": "his childhood home of number four", "start": 5361.639, "duration": 4.681 }, { "text": "private drive but because python knows", "start": 5363.639, "duration": 4.641 }, { "text": "that wait a minute you're trying to", "start": 5366.32, "duration": 5.12 }, { "text": "assign that is set a value and that", "start": 5368.28, "duration": 6.08 }, { "text": "value AKA house is now defined as a", "start": 5371.44, "duration": 4.56 }, { "text": "property you're going to have to go", "start": 5374.36, "duration": 4.08 }, { "text": "through the setter function instead to", "start": 5376.0, "duration": 5.199 }, { "text": "even let you change that value and", "start": 5378.44, "duration": 5.799 }, { "text": "because I have this rais value error if", "start": 5381.199, "duration": 5.48 }, { "text": "the house is not as intended you're not", "start": 5384.239, "duration": 3.92 }, { "text": "going to be allowed to change it to an", "start": 5386.679, "duration": 3.761 }, { "text": "invalid value so I'm protecting the data", "start": 5388.159, "duration": 4.241 }, { "text": "on the way in through the init method", "start": 5390.44, "duration": 4.56 }, { "text": "and I'm even defending the data if you", "start": 5392.4, "duration": 4.839 }, { "text": "try to override it there so I think the", "start": 5395.0, "duration": 4.28 }, { "text": "only solution for me the programmer is", "start": 5397.239, "duration": 4.161 }, { "text": "don't try to break my own code let me", "start": 5399.28, "duration": 3.68 }, { "text": "remove that line because it's just not", "start": 5401.4, "duration": 3.6 }, { "text": "going to work let me run python of", "start": 5402.96, "duration": 4.52 }, { "text": "studenty and again type in Harry type in", "start": 5405.0, "duration": 4.84 }, { "text": "griffindor enter and Harry is indeed", "start": 5407.48, "duration": 4.239 }, { "text": "from Gryffindor if I did something", "start": 5409.84, "duration": 6.04 }, { "text": "incorrect like Harry from number four", "start": 5411.719, "duration": 7.52 }, { "text": "Private Drive enter we're again going to", "start": 5415.88, "duration": 5.52 }, { "text": "see the value error because my code just", "start": 5419.239, "duration": 5.0 }, { "text": "doesn't let that value in Via manual", "start": 5421.4, "duration": 7.0 }, { "text": "input now or via that adversarial change", "start": 5424.239, "duration": 6.161 }, { "text": "all right that was a lot but any", "start": 5428.4, "duration": 5.4 }, { "text": "question on", "start": 5430.4, "duration": 5.839 }, { "text": "properties uh while we are using gets", "start": 5433.8, "duration": 4.48 }, { "text": "and Setters it's just for the purpose so", "start": 5436.239, "duration": 5.201 }, { "text": "that we can find that um that function", "start": 5438.28, "duration": 6.16 }, { "text": "that method that function in in our code", "start": 5441.44, "duration": 4.44 }, { "text": "the reason that I'm going through the", "start": 5444.44, "duration": 2.84 }, { "text": "trouble of defining this getter or", "start": 5445.88, "duration": 4.359 }, { "text": "Setter is because I want to make sure", "start": 5447.28, "duration": 5.56 }, { "text": "that programmers can not do things like", "start": 5450.239, "duration": 4.281 }, { "text": "this if I'm going through the trouble of", "start": 5452.84, "duration": 4.64 }, { "text": "validating the attributes for these", "start": 5454.52, "duration": 4.88 }, { "text": "student objects I don't want you to be", "start": 5457.48, "duration": 3.639 }, { "text": "able to go in there and just change them", "start": 5459.4, "duration": 4.44 }, { "text": "at will I want to have some control over", "start": 5461.119, "duration": 4.161 }, { "text": "that object so that you can just trust", "start": 5463.84, "duration": 2.96 }, { "text": "that it's going to be correct as", "start": 5465.28, "duration": 4.2 }, { "text": "designed so using a getter and Setter", "start": 5466.8, "duration": 4.8 }, { "text": "really just enables python to", "start": 5469.48, "duration": 3.84 }, { "text": "automatically detect when you're trying", "start": 5471.6, "duration": 4.8 }, { "text": "to manually set a value the equal sign", "start": 5473.32, "duration": 5.2 }, { "text": "and the dot as I've highlighted here is", "start": 5476.4, "duration": 3.68 }, { "text": "enough of a clue to python to realize", "start": 5478.52, "duration": 2.719 }, { "text": "wait a minute you're trying to set a", "start": 5480.08, "duration": 3.559 }, { "text": "value let me see if this class has a", "start": 5481.239, "duration": 4.44 }, { "text": "Setter defined and if so I'm going to", "start": 5483.639, "duration": 3.281 }, { "text": "call that and I'm not just going to", "start": 5485.679, "duration": 3.721 }, { "text": "blindly assign the value from right to", "start": 5486.92, "duration": 5.56 }, { "text": "left so it's just giving me more control", "start": 5489.4, "duration": 5.92 }, { "text": "other questions on properties when we", "start": 5492.48, "duration": 6.96 }, { "text": "use a gets we use have just one argument", "start": 5495.32, "duration": 6.72 }, { "text": "and if we use Setters it's always going", "start": 5499.44, "duration": 5.199 }, { "text": "to be two arguments is that normal", "start": 5502.04, "duration": 4.24 }, { "text": "correct it's always going to be one", "start": 5504.639, "duration": 4.361 }, { "text": "argument self for the getter two", "start": 5506.28, "duration": 5.08 }, { "text": "arguments for the setter self and", "start": 5509.0, "duration": 4.679 }, { "text": "something else and the intuition for", "start": 5511.36, "duration": 4.0 }, { "text": "that is if you're getting a value you", "start": 5513.679, "duration": 3.281 }, { "text": "don't need to pass anything else in", "start": 5515.36, "duration": 3.52 }, { "text": "because you already know the object it's", "start": 5516.96, "duration": 3.48 }, { "text": "called student in this case so you're", "start": 5518.88, "duration": 3.04 }, { "text": "just going to get the value of that", "start": 5520.44, "duration": 3.719 }, { "text": "property but if you want to set the", "start": 5521.92, "duration": 3.88 }, { "text": "property to something else you got to", "start": 5524.159, "duration": 3.761 }, { "text": "pass in that argument you've got to pass", "start": 5525.8, "duration": 3.68 }, { "text": "in the value to which you want to set it", "start": 5527.92, "duration": 4.279 }, { "text": "so it's always zero or one however you", "start": 5529.48, "duration": 6.28 }, { "text": "see it as one or two because again any", "start": 5532.199, "duration": 6.641 }, { "text": "function inside of a class AKA a method", "start": 5535.76, "duration": 5.2 }, { "text": "is going to be automatically passed self", "start": 5538.84, "duration": 4.44 }, { "text": "so that you have access to that current", "start": 5540.96, "duration": 4.759 }, { "text": "object in memory how about one other", "start": 5543.28, "duration": 6.12 }, { "text": "question on properties why didn't we use", "start": 5545.719, "duration": 6.601 }, { "text": "the same underscore house in init meod a", "start": 5549.4, "duration": 4.719 }, { "text": "good question so even though I'm using", "start": 5552.32, "duration": 4.28 }, { "text": "the underscore house here in my Setter", "start": 5554.119, "duration": 4.201 }, { "text": "and the underscore house here in my", "start": 5556.6, "duration": 4.559 }, { "text": "getter I deliberately did not use it up", "start": 5558.32, "duration": 5.64 }, { "text": "here the reason for that is that by", "start": 5561.159, "duration": 6.161 }, { "text": "using self. house and this equal sign", "start": 5563.96, "duration": 5.08 }, { "text": "that's the same pattern that I want", "start": 5567.32, "duration": 3.879 }, { "text": "python to recognize I want python to", "start": 5569.04, "duration": 4.24 }, { "text": "automat aut atically call the setter", "start": 5571.199, "duration": 4.361 }, { "text": "even when I'm passing in the house via", "start": 5573.28, "duration": 4.879 }, { "text": "the init method if I were to change this", "start": 5575.56, "duration": 5.159 }, { "text": "to do this that would circumvent the", "start": 5578.159, "duration": 5.0 }, { "text": "setter and now there's no error checking", "start": 5580.719, "duration": 5.161 }, { "text": "in in it whatsoever so it's such a fine", "start": 5583.159, "duration": 4.841 }, { "text": "line the only thing standing between us", "start": 5585.88, "duration": 4.04 }, { "text": "and error checking or no error checking", "start": 5588.0, "duration": 3.8 }, { "text": "is the presence or absence of this", "start": 5589.92, "duration": 3.92 }, { "text": "underscore but that's typically the", "start": 5591.8, "duration": 4.359 }, { "text": "convention by not using the underscore", "start": 5593.84, "duration": 4.12 }, { "text": "there make sure that even that", "start": 5596.159, "duration": 3.681 }, { "text": "assignment goes through the setter so", "start": 5597.96, "duration": 3.719 }, { "text": "that honestly I don't have to copy paste", "start": 5599.84, "duration": 3.64 }, { "text": "the same error checking in two places I", "start": 5601.679, "duration": 3.841 }, { "text": "can put it just in the setter so it's", "start": 5603.48, "duration": 4.239 }, { "text": "better design and that's why I manually", "start": 5605.52, "duration": 3.84 }, { "text": "retyped it at first but then I deleted", "start": 5607.719, "duration": 4.361 }, { "text": "it from in it well allow me to propose", "start": 5609.36, "duration": 4.56 }, { "text": "that we make one other change to this", "start": 5612.08, "duration": 4.48 }, { "text": "file might as well go ahead and Define a", "start": 5613.92, "duration": 5.08 }, { "text": "property for name as well and let me go", "start": 5616.56, "duration": 4.28 }, { "text": "ahead and do this maybe above the house", "start": 5619.0, "duration": 4.0 }, { "text": "property just to keep things uh in the", "start": 5620.84, "duration": 4.24 }, { "text": "same order as I defined them earlier let", "start": 5623.0, "duration": 4.48 }, { "text": "me give myself another property this", "start": 5625.08, "duration": 4.159 }, { "text": "one's going to be called name it's going", "start": 5627.48, "duration": 3.48 }, { "text": "to take one argument called self as", "start": 5629.239, "duration": 3.681 }, { "text": "always and this one very similarly is", "start": 5630.96, "duration": 4.719 }, { "text": "just going to return self doore name so", "start": 5632.92, "duration": 4.199 }, { "text": "I'm going to anticipate that I'm going", "start": 5635.679, "duration": 4.04 }, { "text": "to have to rename name also so that I", "start": 5637.119, "duration": 4.761 }, { "text": "don't have that same Collision as before", "start": 5639.719, "duration": 3.881 }, { "text": "but now let me go ahead and Define", "start": 5641.88, "duration": 4.839 }, { "text": "another uh setter this one for name so", "start": 5643.6, "duration": 6.039 }, { "text": "the convention is at name. Setter why", "start": 5646.719, "duration": 5.96 }, { "text": "name because the property I just created", "start": 5649.639, "duration": 5.48 }, { "text": "is called name so the getter and Setter", "start": 5652.679, "duration": 4.52 }, { "text": "sort of work in conjunction in that in", "start": 5655.119, "duration": 4.52 }, { "text": "this way if you will let me go down", "start": 5657.199, "duration": 4.601 }, { "text": "under atame Setter and Define a another", "start": 5659.639, "duration": 4.201 }, { "text": "function also called name but the key", "start": 5661.8, "duration": 3.72 }, { "text": "thing here is that it's not identical", "start": 5663.84, "duration": 3.92 }, { "text": "it's not the exact same function name", "start": 5665.52, "duration": 4.48 }, { "text": "and the exact same number of arguments", "start": 5667.76, "duration": 4.68 }, { "text": "the setter again takes a second argument", "start": 5670.0, "duration": 3.84 }, { "text": "and I can call it anything I want but", "start": 5672.44, "duration": 2.759 }, { "text": "I'm going to call it name because that's", "start": 5673.84, "duration": 3.359 }, { "text": "what's being passed in and I'm going to", "start": 5675.199, "duration": 4.361 }, { "text": "air put my error checking here if not", "start": 5677.199, "duration": 4.641 }, { "text": "name just like we used to do let's go", "start": 5679.56, "duration": 4.32 }, { "text": "ahead and raise a value error and let's", "start": 5681.84, "duration": 4.399 }, { "text": "put an explanatory message like uh", "start": 5683.88, "duration": 5.52 }, { "text": "Missing name quote unquote otherwise", "start": 5686.239, "duration": 6.681 }, { "text": "let's go ahead and update self doore", "start": 5689.4, "duration": 6.799 }, { "text": "name to equal name and I don't have to", "start": 5692.92, "duration": 5.92 }, { "text": "change in it except to get rid of this", "start": 5696.199, "duration": 5.321 }, { "text": "duplicate error checking now because", "start": 5698.84, "duration": 6.44 }, { "text": "again if I use self. name equals here", "start": 5701.52, "duration": 5.96 }, { "text": "and self. house equals here with no", "start": 5705.28, "duration": 4.56 }, { "text": "underscore both of those assignments are", "start": 5707.48, "duration": 4.8 }, { "text": "going to go through my two Setter", "start": 5709.84, "duration": 4.48 }, { "text": "functions now before we run this let me", "start": 5712.28, "duration": 3.839 }, { "text": "go ahead and remove this adversarial", "start": 5714.32, "duration": 3.319 }, { "text": "code which we know won't work because", "start": 5716.119, "duration": 3.56 }, { "text": "we're catching it let me go back down to", "start": 5717.639, "duration": 3.801 }, { "text": "my terminal window and run python of", "start": 5719.679, "duration": 4.321 }, { "text": "studenty enter let's type in Harry let's", "start": 5721.44, "duration": 4.4 }, { "text": "type in Gryffindor and that seems to", "start": 5724.0, "duration": 4.159 }, { "text": "work let's try though again to run", "start": 5725.84, "duration": 4.359 }, { "text": "python of studenty with Harry from", "start": 5728.159, "duration": 5.441 }, { "text": "number four private drive this will not", "start": 5730.199, "duration": 6.241 }, { "text": "work a value error with invalid house", "start": 5733.6, "duration": 4.079 }, { "text": "because that's not one of the four", "start": 5736.44, "duration": 3.279 }, { "text": "Hogwarts houses and now for good measure", "start": 5737.679, "duration": 3.641 }, { "text": "let's run it one more time and let's not", "start": 5739.719, "duration": 3.641 }, { "text": "even give it a name let's just hit enter", "start": 5741.32, "duration": 4.12 }, { "text": "when prompted I can type anything for", "start": 5743.36, "duration": 3.4 }, { "text": "the house I'll go ahead and still give", "start": 5745.44, "duration": 3.64 }, { "text": "it Gryffindor enter now we get another", "start": 5746.76, "duration": 5.16 }, { "text": "value error but this one is for missing", "start": 5749.08, "duration": 5.48 }, { "text": "name so we seem now to have all the more", "start": 5751.92, "duration": 4.799 }, { "text": "of a defense mechanism in place to", "start": 5754.56, "duration": 4.28 }, { "text": "ensure that name is as we expect it's", "start": 5756.719, "duration": 4.361 }, { "text": "got to have some value that's not blank", "start": 5758.84, "duration": 4.04 }, { "text": "and houses as we expect it's got to have", "start": 5761.08, "duration": 5.0 }, { "text": "one of those four values but at the risk", "start": 5762.88, "duration": 5.319 }, { "text": "of bursting everyone's bubble and making", "start": 5766.08, "duration": 4.48 }, { "text": "you wonder why did we just go through", "start": 5768.199, "duration": 6.281 }, { "text": "all of that unfortunately python really", "start": 5770.56, "duration": 7.28 }, { "text": "focuses on conventions not hard", "start": 5774.48, "duration": 5.96 }, { "text": "constraints and by that I mean this if I", "start": 5777.84, "duration": 5.2 }, { "text": "go back into my function after I've", "start": 5780.44, "duration": 5.679 }, { "text": "gotten a student on line 30 and I try to", "start": 5783.04, "duration": 5.159 }, { "text": "adversarially do something like this", "start": 5786.119, "duration": 4.161 }, { "text": "student. housee equals quote unquote", "start": 5788.199, "duration": 5.161 }, { "text": "number four Private Drive we know this", "start": 5790.28, "duration": 5.6 }, { "text": "won't work because my Setter for house", "start": 5793.36, "duration": 5.0 }, { "text": "is going to catch this watch again", "start": 5795.88, "duration": 3.72 }, { "text": "python of", "start": 5798.36, "duration": 3.799 }, { "text": "studenty uh let's type in Harry let's", "start": 5799.6, "duration": 4.44 }, { "text": "type in Gryffindor which will at least", "start": 5802.159, "duration": 4.96 }, { "text": "pass our check that's induced by in it", "start": 5804.04, "duration": 6.679 }, { "text": "but line 31 is going to trigger the same", "start": 5807.119, "duration": 5.12 }, { "text": "Setter to be be called and we're going", "start": 5810.719, "duration": 3.92 }, { "text": "to raise a value error saying invalid", "start": 5812.239, "duration": 5.201 }, { "text": "house unfortunately and if some of you", "start": 5814.639, "duration": 4.48 }, { "text": "are already thinking a little", "start": 5817.44, "duration": 3.84 }, { "text": "adversarially tragically look what you", "start": 5819.119, "duration": 5.961 }, { "text": "can do you can change house to be uncore", "start": 5821.28, "duration": 6.359 }, { "text": "house why well the instance variable is", "start": 5825.08, "duration": 6.159 }, { "text": "now called underscore house the property", "start": 5827.639, "duration": 5.761 }, { "text": "is called house no underscore but the", "start": 5831.239, "duration": 4.48 }, { "text": "underlying attribute implemented as an", "start": 5833.4, "duration": 5.16 }, { "text": "instance variable is still called", "start": 5835.719, "duration": 6.121 }, { "text": "underscore house and tragically python", "start": 5838.56, "duration": 6.559 }, { "text": "of student. py let's type in Harry let's", "start": 5841.84, "duration": 5.6 }, { "text": "type in Gryffindor which is correct but", "start": 5845.119, "duration": 5.401 }, { "text": "Watch What Happens now oh my God we", "start": 5847.44, "duration": 6.44 }, { "text": "slipped through so what was the point of", "start": 5850.52, "duration": 5.48 }, { "text": "all of this emphasis from me on doing", "start": 5853.88, "duration": 4.52 }, { "text": "things the right way the pythonic way by", "start": 5856.0, "duration": 4.48 }, { "text": "having this getter and Setter well", "start": 5858.4, "duration": 4.799 }, { "text": "unlike languages like Java that just", "start": 5860.48, "duration": 5.119 }, { "text": "prevent you from doing things like this", "start": 5863.199, "duration": 4.361 }, { "text": "python itself allows you to specify that", "start": 5865.599, "duration": 3.961 }, { "text": "certain instance variables can be public", "start": 5867.56, "duration": 4.2 }, { "text": "and accessible to anyone's code or", "start": 5869.56, "duration": 4.84 }, { "text": "protected or private which means that no", "start": 5871.76, "duration": 4.2 }, { "text": "one else should be able to change these", "start": 5874.4, "duration": 4.48 }, { "text": "values in the world of python it's just", "start": 5875.96, "duration": 5.159 }, { "text": "the honor System it's not baked into the", "start": 5878.88, "duration": 3.92 }, { "text": "language itself that there's a notion of", "start": 5881.119, "duration": 3.52 }, { "text": "visibility public or private or even", "start": 5882.8, "duration": 3.919 }, { "text": "somewhere in between protected instead", "start": 5884.639, "duration": 3.52 }, { "text": "you're on the honor System and the", "start": 5886.719, "duration": 4.801 }, { "text": "convention generally is if a instance", "start": 5888.159, "duration": 6.161 }, { "text": "variable starts with an underscore", "start": 5891.52, "duration": 4.84 }, { "text": "please don't touch it like just don't", "start": 5894.32, "duration": 3.96 }, { "text": "like that's on you if you touch that", "start": 5896.36, "duration": 4.0 }, { "text": "variable and break things the underscore", "start": 5898.28, "duration": 3.72 }, { "text": "is meant to signify a convention that", "start": 5900.36, "duration": 3.759 }, { "text": "this is meant to be private but it", "start": 5902.0, "duration": 3.56 }, { "text": "really just means please don't touch", "start": 5904.119, "duration": 2.52 }, { "text": "this sometimes if there's two", "start": 5905.56, "duration": 2.88 }, { "text": "underscores which you can use two that's", "start": 5906.639, "duration": 3.52 }, { "text": "an even greater effort by programmers to", "start": 5908.44, "duration": 3.719 }, { "text": "say really don't touch this but", "start": 5910.159, "duration": 3.56 }, { "text": "technically speaking there's nothing", "start": 5912.159, "duration": 4.161 }, { "text": "stopping you or me from circumventing", "start": 5913.719, "duration": 5.0 }, { "text": "all of these mechanisms these properties", "start": 5916.32, "duration": 3.96 }, { "text": "these Getters and Setters we're", "start": 5918.719, "duration": 3.561 }, { "text": "ultimately just on the honor System not", "start": 5920.28, "duration": 4.359 }, { "text": "to do so when we see instance variables", "start": 5922.28, "duration": 4.8 }, { "text": "prefixed with one or perhaps even two", "start": 5924.639, "duration": 4.881 }, { "text": "underscores all right so this is a lot", "start": 5927.08, "duration": 4.119 }, { "text": "all at once this introduction to", "start": 5929.52, "duration": 4.079 }, { "text": "object-oriented programming but it might", "start": 5931.199, "duration": 4.48 }, { "text": "come as quite a surprise that even", "start": 5933.599, "duration": 5.201 }, { "text": "though we might have identified oop by", "start": 5935.679, "duration": 6.761 }, { "text": "name in weeks past we've all been using", "start": 5938.8, "duration": 6.16 }, { "text": "classes and objects for weeks now in", "start": 5942.44, "duration": 4.32 }, { "text": "this class in fact if you think back on", "start": 5944.96, "duration": 3.239 }, { "text": "one of the very first things we did in", "start": 5946.76, "duration": 3.479 }, { "text": "this class we used integers and just got", "start": 5948.199, "duration": 4.4 }, { "text": "integers from the user but if you", "start": 5950.239, "duration": 4.841 }, { "text": "haven't already if you go and dig into", "start": 5952.599, "duration": 4.961 }, { "text": "the documentation for integers which", "start": 5955.08, "duration": 4.96 }, { "text": "again lives at this URL here you would", "start": 5957.56, "duration": 6.559 }, { "text": "actually find that int itself is and has", "start": 5960.04, "duration": 7.119 }, { "text": "been for weeks a class and in fact this", "start": 5964.119, "duration": 5.161 }, { "text": "is the signature of the Constructor call", "start": 5967.159, "duration": 5.52 }, { "text": "for an INT whereby you pass in X like a", "start": 5969.28, "duration": 6.08 }, { "text": "number quote unquote 50 or quote unquote", "start": 5972.679, "duration": 4.881 }, { "text": "something else you pass in optionally", "start": 5975.36, "duration": 5.239 }, { "text": "the base 10 for decimal two for binary", "start": 5977.56, "duration": 5.88 }, { "text": "or anything else and that int function", "start": 5980.599, "duration": 4.961 }, { "text": "will actually return to you all this", "start": 5983.44, "duration": 6.679 }, { "text": "time an object of type int that is to", "start": 5985.56, "duration": 7.36 }, { "text": "say int is a class it is a template a", "start": 5990.119, "duration": 4.52 }, { "text": "blueprint for creating integers in", "start": 5992.92, "duration": 3.679 }, { "text": "memory and anytime you and I have", "start": 5994.639, "duration": 3.761 }, { "text": "converted a string for instance to an", "start": 5996.599, "duration": 4.801 }, { "text": "INT you and I have been creating an", "start": 5998.4, "duration": 5.44 }, { "text": "object of type int that was calling", "start": 6001.4, "duration": 5.12 }, { "text": "apparently the underscore uncore init", "start": 6003.84, "duration": 4.2 }, { "text": "underscore underscore method that", "start": 6006.52, "duration": 3.44 }, { "text": "someone else the authors of python wrote", "start": 6008.04, "duration": 4.559 }, { "text": "to give us back that proper integer", "start": 6009.96, "duration": 5.32 }, { "text": "besides that if you can believe it stirs", "start": 6012.599, "duration": 4.841 }, { "text": "strings in Python have been classes", "start": 6015.28, "duration": 4.0 }, { "text": "since the first week of this class as", "start": 6017.44, "duration": 3.719 }, { "text": "well if you look up the documentation", "start": 6019.28, "duration": 4.24 }, { "text": "for a stir which lives at a similar URL", "start": 6021.159, "duration": 4.321 }, { "text": "there you will find that when you", "start": 6023.52, "duration": 4.88 }, { "text": "instantiate that is create a stir it", "start": 6025.48, "duration": 5.92 }, { "text": "takes optionally a parameter called", "start": 6028.4, "duration": 4.68 }, { "text": "object here the default value of which", "start": 6031.4, "duration": 3.719 }, { "text": "is just quote unquote which allows you", "start": 6033.08, "duration": 3.92 }, { "text": "to create in effect an empty string a", "start": 6035.119, "duration": 4.321 }, { "text": "blank string if you will but anytime you", "start": 6037.0, "duration": 4.639 }, { "text": "and I have created stirs or even used", "start": 6039.44, "duration": 4.32 }, { "text": "explicitly this stir function you are", "start": 6041.639, "duration": 5.801 }, { "text": "getting back an object of type stir", "start": 6043.76, "duration": 5.68 }, { "text": "anytime you and I have forced a string", "start": 6047.44, "duration": 5.239 }, { "text": "to lowercase per the documentation using", "start": 6049.44, "duration": 5.48 }, { "text": "syntax like this you and I have been", "start": 6052.679, "duration": 5.56 }, { "text": "taking an object of type stir and", "start": 6054.92, "duration": 5.96 }, { "text": "forcing it all to lowercase by calling a", "start": 6058.239, "duration": 5.88 }, { "text": "method called Lower a method that the", "start": 6060.88, "duration": 6.52 }, { "text": "authors of python built into the stir", "start": 6064.119, "duration": 5.361 }, { "text": "class but it's been there from the gecko", "start": 6067.4, "duration": 3.64 }, { "text": "so this notion of methods is not even", "start": 6069.48, "duration": 3.36 }, { "text": "new today you would have been doing it", "start": 6071.04, "duration": 3.199 }, { "text": "for this long if you've ever called", "start": 6072.84, "duration": 3.24 }, { "text": "strip to remove the leading and the", "start": 6074.239, "duration": 3.761 }, { "text": "trailing Whit space from a string in", "start": 6076.08, "duration": 4.079 }, { "text": "Python you are calling another method", "start": 6078.0, "duration": 4.48 }, { "text": "that came with with python written by", "start": 6080.159, "duration": 3.881 }, { "text": "the authors of python and even though we", "start": 6082.48, "duration": 3.6 }, { "text": "didn't call it a class at the time a", "start": 6084.04, "duration": 6.159 }, { "text": "stir all this time has been a class and", "start": 6086.08, "duration": 6.8 }, { "text": "instances of strings are themselves", "start": 6090.199, "duration": 4.881 }, { "text": "objects and those objects come therefore", "start": 6092.88, "duration": 4.16 }, { "text": "with these functions built in AKA", "start": 6095.08, "duration": 3.8 }, { "text": "methods that allow us to do things like", "start": 6097.04, "duration": 4.24 }, { "text": "force to lowercase and strip Whit space", "start": 6098.88, "duration": 4.44 }, { "text": "from the beginning and end let's do", "start": 6101.28, "duration": 4.56 }, { "text": "another list anytime you've created a", "start": 6103.32, "duration": 5.76 }, { "text": "list either uh either syntactically with", "start": 6105.84, "duration": 5.319 }, { "text": "square brackets or literally with l l i", "start": 6109.08, "duration": 4.2 }, { "text": "s open parenthesis close parenthesis", "start": 6111.159, "duration": 4.0 }, { "text": "which is also possible you have been", "start": 6113.28, "duration": 3.56 }, { "text": "using a class if you go to the", "start": 6115.159, "duration": 4.0 }, { "text": "documentation for list at this similar", "start": 6116.84, "duration": 4.64 }, { "text": "URL here or more specifically the", "start": 6119.159, "duration": 4.881 }, { "text": "tutorial on lists here in Python you", "start": 6121.48, "duration": 5.52 }, { "text": "will see that a list is and has been", "start": 6124.04, "duration": 5.44 }, { "text": "since the early weeks of this class A", "start": 6127.0, "duration": 6.679 }, { "text": "Class itself and that list class takes", "start": 6129.48, "duration": 6.719 }, { "text": "as part of its uh initialization an", "start": 6133.679, "duration": 4.56 }, { "text": "optional iterable something that can be", "start": 6136.199, "duration": 4.641 }, { "text": "iterated over like one comma 2 comma 3", "start": 6138.239, "duration": 5.121 }, { "text": "or some list of values and you can then", "start": 6140.84, "duration": 5.12 }, { "text": "get back a list containing those same", "start": 6143.36, "duration": 5.2 }, { "text": "iterable values if you've ever appended", "start": 6145.96, "duration": 4.84 }, { "text": "something to a list in this class as I", "start": 6148.56, "duration": 3.8 }, { "text": "have myself in the past you've been", "start": 6150.8, "duration": 4.52 }, { "text": "using a method called aend that comes", "start": 6152.36, "duration": 5.08 }, { "text": "with the list class that per the X here", "start": 6155.32, "duration": 3.839 }, { "text": "takes an argument that allows you to", "start": 6157.44, "duration": 5.32 }, { "text": "append something to the current list AKA", "start": 6159.159, "duration": 5.96 }, { "text": "self in the context of that method we", "start": 6162.76, "duration": 4.0 }, { "text": "can do this all day long if you've used", "start": 6165.119, "duration": 4.641 }, { "text": "a dictionary or a dict in Python I've", "start": 6166.76, "duration": 4.839 }, { "text": "actually all this time been calling them", "start": 6169.76, "duration": 4.76 }, { "text": "dict objects and that's for a reason", "start": 6171.599, "duration": 5.12 }, { "text": "dict itself is a class in Python if you", "start": 6174.52, "duration": 4.679 }, { "text": "pull up its official documentation here", "start": 6176.719, "duration": 4.96 }, { "text": "and you'll see that it is defined indeed", "start": 6179.199, "duration": 4.881 }, { "text": "as itself a class and that class comes", "start": 6181.679, "duration": 4.0 }, { "text": "with methods as well and so anytime", "start": 6184.08, "duration": 3.44 }, { "text": "we've manipulated dictionaries we've", "start": 6185.679, "duration": 4.881 }, { "text": "been in underneath the hood using all of", "start": 6187.52, "duration": 4.84 }, { "text": "those same methods and in fact we can", "start": 6190.56, "duration": 3.84 }, { "text": "see this if we're really curious let me", "start": 6192.36, "duration": 5.2 }, { "text": "go back over here to VSS code and let me", "start": 6194.4, "duration": 5.04 }, { "text": "go ahead and create a new file that very", "start": 6197.56, "duration": 3.92 }, { "text": "simply does something like play around", "start": 6199.44, "duration": 3.679 }, { "text": "with data types and let me go ahead and", "start": 6201.48, "duration": 3.92 }, { "text": "create a new file for instance called", "start": 6203.119, "duration": 5.801 }, { "text": "say uh type. piy just so that I can poke", "start": 6205.4, "duration": 6.199 }, { "text": "around inside of some values and in", "start": 6208.92, "duration": 4.64 }, { "text": "type. pi I'm just going to go ahead and", "start": 6211.599, "duration": 4.12 }, { "text": "do this I'm going to print out whatever", "start": 6213.56, "duration": 5.079 }, { "text": "the type is of say the number 50 and", "start": 6215.719, "duration": 4.0 }, { "text": "this is a function you've not", "start": 6218.639, "duration": 3.121 }, { "text": "necessarily seen me use already and it's", "start": 6219.719, "duration": 4.121 }, { "text": "not one you would frequently use in your", "start": 6221.76, "duration": 3.959 }, { "text": "own code there are other ways to te", "start": 6223.84, "duration": 3.64 }, { "text": "detect if you need to what the type is", "start": 6225.719, "duration": 5.041 }, { "text": "of a variable but in this case type of", "start": 6227.48, "duration": 5.679 }, { "text": "50 is just going to tell me and then", "start": 6230.76, "duration": 4.359 }, { "text": "print out what the data type is of that", "start": 6233.159, "duration": 3.881 }, { "text": "value now hopefully all of us could", "start": 6235.119, "duration": 3.6 }, { "text": "guess that 50 is indeed going to be an", "start": 6237.04, "duration": 4.28 }, { "text": "integer that is an INT but we can see it", "start": 6238.719, "duration": 4.081 }, { "text": "in this way and this too is what's", "start": 6241.32, "duration": 2.64 }, { "text": "powerful about knowing a bit of", "start": 6242.8, "duration": 2.16 }, { "text": "programming if you want to know the", "start": 6243.96, "duration": 3.04 }, { "text": "answer to a question just try it out", "start": 6244.96, "duration": 3.8 }, { "text": "like I am here so let me go ahead and", "start": 6247.0, "duration": 4.48 }, { "text": "run python of type. piy enter and there", "start": 6248.76, "duration": 5.72 }, { "text": "it is when you print out the type of the", "start": 6251.48, "duration": 5.96 }, { "text": "number 50 you'll see on the screen in", "start": 6254.48, "duration": 5.44 }, { "text": "this cryptic syntax class quotee unquote", "start": 6257.44, "duration": 4.159 }, { "text": "in this is not something that you", "start": 6259.92, "duration": 3.719 }, { "text": "probably want to show to the user but if", "start": 6261.599, "duration": 3.721 }, { "text": "you yourself just want to poke around", "start": 6263.639, "duration": 3.681 }, { "text": "and see what's going on or maybe use", "start": 6265.32, "duration": 4.12 }, { "text": "that information somehow it's certainly", "start": 6267.32, "duration": 4.279 }, { "text": "at your disposal to use with this type", "start": 6269.44, "duration": 4.0 }, { "text": "function for that let's change it around", "start": 6271.599, "duration": 4.201 }, { "text": "a little bit instead of passing as the", "start": 6273.44, "duration": 5.32 }, { "text": "argument to type 50 as an INT let's type", "start": 6275.8, "duration": 4.919 }, { "text": "something also familiar like hello comma", "start": 6278.76, "duration": 4.56 }, { "text": "World in double or single quotes let me", "start": 6280.719, "duration": 4.281 }, { "text": "go back to my terminal window clear the", "start": 6283.32, "duration": 3.919 }, { "text": "screen and run python of type. again and", "start": 6285.0, "duration": 5.56 }, { "text": "now voila there it is all this time a", "start": 6287.239, "duration": 6.0 }, { "text": "sure is also a class we can do this a", "start": 6290.56, "duration": 4.28 }, { "text": "few more times for instance let's go", "start": 6293.239, "duration": 4.321 }, { "text": "ahead and change hello world to just an", "start": 6294.84, "duration": 5.48 }, { "text": "empty list open square bracket close", "start": 6297.56, "duration": 4.36 }, { "text": "square bracket and this is starting to", "start": 6300.32, "duration": 3.64 }, { "text": "look a little cryptic but again notice", "start": 6301.92, "duration": 3.96 }, { "text": "what I'm doing in square brackets is an", "start": 6303.96, "duration": 4.4 }, { "text": "empty list we've done that before that", "start": 6305.88, "duration": 4.839 }, { "text": "is the sole argument to this new type", "start": 6308.36, "duration": 5.04 }, { "text": "function and that's just being passed to", "start": 6310.719, "duration": 4.801 }, { "text": "the print function so that the return", "start": 6313.4, "duration": 5.0 }, { "text": "value of type is the argument to print", "start": 6315.52, "duration": 5.119 }, { "text": "so if I now run this code python of", "start": 6318.4, "duration": 6.12 }, { "text": "type. there it is a list is a class two", "start": 6320.639, "duration": 5.761 }, { "text": "you might recall that I said that you", "start": 6324.52, "duration": 3.44 }, { "text": "can also create an empty list by", "start": 6326.4, "duration": 3.759 }, { "text": "literally doing list open parenthesis", "start": 6327.96, "duration": 4.56 }, { "text": "close parenthesis this is a bit of an", "start": 6330.159, "duration": 4.801 }, { "text": "inconsistency as we can now identify", "start": 6332.52, "duration": 5.84 }, { "text": "that int and stir and Now list they're", "start": 6334.96, "duration": 5.36 }, { "text": "technically all lowercase and I went to", "start": 6338.36, "duration": 4.52 }, { "text": "Great Lengths of creating my student", "start": 6340.32, "duration": 5.44 }, { "text": "class to have that capital S that's a", "start": 6342.88, "duration": 6.12 }, { "text": "convention because int and stir and list", "start": 6345.76, "duration": 6.56 }, { "text": "and others come with py Pon they decided", "start": 6349.0, "duration": 5.4 }, { "text": "to make their buil-in data types even", "start": 6352.32, "duration": 4.24 }, { "text": "though their classes all lowercase but", "start": 6354.4, "duration": 4.04 }, { "text": "the convention the recommendation in the", "start": 6356.56, "duration": 3.24 }, { "text": "python Community when creating your", "start": 6358.44, "duration": 3.759 }, { "text": "classes is indeed to capitalize the", "start": 6359.8, "duration": 4.28 }, { "text": "first letter as I did in something like", "start": 6362.199, "duration": 5.0 }, { "text": "student capital S but list open", "start": 6364.08, "duration": 4.8 }, { "text": "parenthesis closed parenthesis is", "start": 6367.199, "duration": 3.681 }, { "text": "identical to really just two empty", "start": 6368.88, "duration": 4.16 }, { "text": "square brackets if I clear my screen and", "start": 6370.88, "duration": 5.0 }, { "text": "run type. again you see the exact same", "start": 6373.04, "duration": 5.079 }, { "text": "thing the class is called list let's do", "start": 6375.88, "duration": 4.96 }, { "text": "one more let me change list to not", "start": 6378.119, "duration": 4.921 }, { "text": "square brackets but curly braces we've", "start": 6380.84, "duration": 4.2 }, { "text": "done this before anytime I've done two", "start": 6383.04, "duration": 4.079 }, { "text": "curly braces with nothing in between", "start": 6385.04, "duration": 4.32 }, { "text": "this of course is an empty dictionary or", "start": 6387.119, "duration": 4.921 }, { "text": "a dict object in Python well we can see", "start": 6389.36, "duration": 4.4 }, { "text": "that now let me clear my screen run", "start": 6392.04, "duration": 3.96 }, { "text": "python of type. piy enter and there it", "start": 6393.76, "duration": 5.04 }, { "text": "is class dick it's been there this whole", "start": 6396.0, "duration": 4.92 }, { "text": "time we just didn't call it a class", "start": 6398.8, "duration": 5.0 }, { "text": "until today I can similarly do this one", "start": 6400.92, "duration": 5.0 }, { "text": "explicitly instead of two curly braces", "start": 6403.8, "duration": 3.72 }, { "text": "let's write out dict with two", "start": 6405.92, "duration": 3.239 }, { "text": "parentheses now we have a lot of", "start": 6407.52, "duration": 4.199 }, { "text": "parentheses again like with list but", "start": 6409.159, "duration": 4.281 }, { "text": "this is just making even more clear that", "start": 6411.719, "duration": 4.561 }, { "text": "the type of a dict object is indeed the", "start": 6413.44, "duration": 6.36 }, { "text": "class dict itself so this is to say that", "start": 6416.28, "duration": 5.48 }, { "text": "as new as a lot of today's IDE and", "start": 6419.8, "duration": 4.0 }, { "text": "syntax might be you've actually been", "start": 6421.76, "duration": 4.04 }, { "text": "using it perhaps unbeknownst to you for", "start": 6423.8, "duration": 4.52 }, { "text": "weeks now we now just have terminology", "start": 6425.8, "duration": 4.28 }, { "text": "to describe what it is we've been doing", "start": 6428.32, "duration": 3.919 }, { "text": "all this time and you now have the", "start": 6430.08, "duration": 4.36 }, { "text": "expressiveness with some practice to", "start": 6432.239, "duration": 4.801 }, { "text": "create your own classes inside of which", "start": 6434.44, "duration": 4.44 }, { "text": "are your own instance variables perhaps", "start": 6437.04, "duration": 3.76 }, { "text": "wrapped with those properties and your", "start": 6438.88, "duration": 5.64 }, { "text": "own instance methods but it turns out", "start": 6440.8, "duration": 5.72 }, { "text": "there's other types of methods in the", "start": 6444.52, "duration": 4.199 }, { "text": "world thus far I've been deliberate in", "start": 6446.52, "duration": 4.44 }, { "text": "calling all of our variables instance", "start": 6448.719, "duration": 5.0 }, { "text": "variables and all of our methods uh", "start": 6450.96, "duration": 5.48 }, { "text": "instance methods it turns out there's", "start": 6453.719, "duration": 6.041 }, { "text": "other types of variables and methods out", "start": 6456.44, "duration": 5.759 }, { "text": "there and one of those is called class", "start": 6459.76, "duration": 5.68 }, { "text": "methods it turns out that sometimes it's", "start": 6462.199, "duration": 6.4 }, { "text": "not really necessary or sensible to", "start": 6465.44, "duration": 6.04 }, { "text": "associate a function with objects of a", "start": 6468.599, "duration": 6.401 }, { "text": "class but rather with the class itself", "start": 6471.48, "duration": 5.92 }, { "text": "an instance or an object of a class is a", "start": 6475.0, "duration": 5.0 }, { "text": "very specific Incarnation thereof again", "start": 6477.4, "duration": 4.44 }, { "text": "on that neighborhood that has a lot of", "start": 6480.0, "duration": 3.56 }, { "text": "identical looking buildings but they're", "start": 6481.84, "duration": 3.16 }, { "text": "all a little bit different because of", "start": 6483.56, "duration": 3.84 }, { "text": "different paint and such sometimes you", "start": 6485.0, "duration": 5.04 }, { "text": "might have functionality related to each", "start": 6487.4, "duration": 5.239 }, { "text": "of those houses that isn't distinct or", "start": 6490.04, "duration": 4.48 }, { "text": "unique for any of the houses it's", "start": 6492.639, "duration": 3.801 }, { "text": "functionality that's going to be exactly", "start": 6494.52, "duration": 4.719 }, { "text": "the same no matter the house in question", "start": 6496.44, "duration": 4.44 }, { "text": "same in the world of object oriented", "start": 6499.239, "duration": 3.521 }, { "text": "programming sometimes you want some", "start": 6500.88, "duration": 3.6 }, { "text": "functionality some action to be", "start": 6502.76, "duration": 4.0 }, { "text": "associated with the class itself no", "start": 6504.48, "duration": 5.32 }, { "text": "matter what the specific objects own", "start": 6506.76, "duration": 5.919 }, { "text": "values or instance variables are and for", "start": 6509.8, "duration": 5.64 }, { "text": "that we have a keyword called at class", "start": 6512.679, "duration": 5.201 }, { "text": "method this is another decorator really", "start": 6515.44, "duration": 4.759 }, { "text": "another function that you can use to", "start": 6517.88, "duration": 5.6 }, { "text": "specify that this method is not by", "start": 6520.199, "duration": 5.681 }, { "text": "default implicitly an instance method", "start": 6523.48, "duration": 4.52 }, { "text": "that has access to self the object", "start": 6525.88, "duration": 4.359 }, { "text": "itself this is a class method that's not", "start": 6528.0, "duration": 3.96 }, { "text": "not going to have access to self but it", "start": 6530.239, "duration": 4.241 }, { "text": "does know what class it's inside so what", "start": 6531.96, "duration": 4.159 }, { "text": "do I mean by this well let me go back to", "start": 6534.48, "duration": 4.0 }, { "text": "vs code here and let me propose that we", "start": 6536.119, "duration": 5.0 }, { "text": "create a new file this time implementing", "start": 6538.48, "duration": 4.84 }, { "text": "the notion of a the Sorting Hat from the", "start": 6541.119, "duration": 4.241 }, { "text": "World of Harry Potter as well to stay on", "start": 6543.32, "duration": 3.799 }, { "text": "theme I'm going to go ahead and run code", "start": 6545.36, "duration": 4.56 }, { "text": "of hat. py and in hat. py let's", "start": 6547.119, "duration": 4.681 }, { "text": "implement the notion of this Sorting Hat", "start": 6549.92, "duration": 3.96 }, { "text": "if unfamiliar in the books and in the", "start": 6551.8, "duration": 5.04 }, { "text": "films there is literally a pointy hat", "start": 6553.88, "duration": 4.96 }, { "text": "that when a student put it on their head", "start": 6556.84, "duration": 4.839 }, { "text": "that Sorting Hat so to speak decides", "start": 6558.84, "duration": 4.48 }, { "text": "what house the student is in whether", "start": 6561.679, "duration": 3.761 }, { "text": "it's Gryffindor or something else so", "start": 6563.32, "duration": 4.12 }, { "text": "let's Implement and code this notion of", "start": 6565.44, "duration": 5.04 }, { "text": "a Sorting Hat such that when we pass to", "start": 6567.44, "duration": 4.84 }, { "text": "the Sorting Hat the name of a student", "start": 6570.48, "duration": 4.04 }, { "text": "like quote unquote Harry this Sorting", "start": 6572.28, "duration": 4.56 }, { "text": "Hat implemented in code will tell us", "start": 6574.52, "duration": 5.199 }, { "text": "what house that student should be in all", "start": 6576.84, "duration": 5.0 }, { "text": "right well let's go ahead and do this in", "start": 6579.719, "duration": 4.96 }, { "text": "hat. py first let's go ahead and define", "start": 6581.84, "duration": 6.279 }, { "text": "a class called hat and then let's get", "start": 6584.679, "duration": 5.121 }, { "text": "back to implementing it itself and I", "start": 6588.119, "duration": 3.04 }, { "text": "find this to be a helpful technique not", "start": 6589.8, "duration": 3.28 }, { "text": "just with teaching but when writing code", "start": 6591.159, "duration": 4.321 }, { "text": "like I know I want a ha class I don't", "start": 6593.08, "duration": 4.119 }, { "text": "necessarily know what I want it to do", "start": 6595.48, "duration": 3.0 }, { "text": "yet so I'm going to create this sort of", "start": 6597.199, "duration": 3.44 }, { "text": "placeholder dot dot dot so I'll come", "start": 6598.48, "duration": 4.84 }, { "text": "back to that let's now try to use this", "start": 6600.639, "duration": 4.641 }, { "text": "class as though it existed and from", "start": 6603.32, "duration": 4.76 }, { "text": "there I perhaps can realize exactly what", "start": 6605.28, "duration": 4.399 }, { "text": "functionality that class needs to have", "start": 6608.08, "duration": 3.96 }, { "text": "to support my use case let me go ahead", "start": 6609.679, "duration": 4.04 }, { "text": "and create a variable called hat in all", "start": 6612.04, "duration": 5.48 }, { "text": "lower case and instantiate a hat object", "start": 6613.719, "duration": 6.52 }, { "text": "so no matter what the Hat class ends up", "start": 6617.52, "duration": 5.199 }, { "text": "looking like this is the common Syntax", "start": 6620.239, "duration": 5.0 }, { "text": "for instantiating an object of a certain", "start": 6622.719, "duration": 5.361 }, { "text": "class in the past we saw student all", "start": 6625.239, "duration": 5.88 }, { "text": "lowercase equals Capital student open", "start": 6628.08, "duration": 4.8 }, { "text": "parenthesis closed parenthesis and then", "start": 6631.119, "duration": 3.401 }, { "text": "eventually we added in things like name", "start": 6632.88, "duration": 4.359 }, { "text": "and house for now let's assume that the", "start": 6634.52, "duration": 4.92 }, { "text": "hat is much simpler than a student and", "start": 6637.239, "duration": 4.201 }, { "text": "it only has sorting capabilities so I'm", "start": 6639.44, "duration": 3.6 }, { "text": "not going to even pass any arguments", "start": 6641.44, "duration": 4.639 }, { "text": "there too indeed let me assume that the", "start": 6643.04, "duration": 6.8 }, { "text": "Sorting Hat has one Function One method", "start": 6646.079, "duration": 6.201 }, { "text": "in inside of it called sort and so if I", "start": 6649.84, "duration": 6.839 }, { "text": "do hat. sort quote unquote Harry let's", "start": 6652.28, "duration": 7.439 }, { "text": "propose that that prints out what house", "start": 6656.679, "duration": 5.841 }, { "text": "that student should be in so that's it", "start": 6659.719, "duration": 5.52 }, { "text": "I'm going to encapsulate that is tuck", "start": 6662.52, "duration": 4.76 }, { "text": "away inside of a hat class all of this", "start": 6665.239, "duration": 4.601 }, { "text": "requisite functionality and I'm going to", "start": 6667.28, "duration": 5.2 }, { "text": "print out onto the screen what hat uh", "start": 6669.84, "duration": 5.239 }, { "text": "what house Harry belongs in all right", "start": 6672.48, "duration": 4.32 }, { "text": "now I think I need to get into the weeds", "start": 6675.079, "duration": 3.0 }, { "text": "of actually", "start": 6676.8, "duration": 3.919 }, { "text": "initializing this class well let me go", "start": 6678.079, "duration": 5.12 }, { "text": "ahead and do this if I don't care to", "start": 6680.719, "duration": 5.92 }, { "text": "parameterize hat I just want to for", "start": 6683.199, "duration": 6.321 }, { "text": "instance uh sort values let's go ahead", "start": 6686.639, "duration": 5.44 }, { "text": "and Define this function sort first so", "start": 6689.52, "duration": 4.679 }, { "text": "let's define sort as taking a first", "start": 6692.079, "duration": 4.201 }, { "text": "argument self which is always going to", "start": 6694.199, "duration": 4.321 }, { "text": "be the case when defining an instance", "start": 6696.28, "duration": 4.359 }, { "text": "method as before but the sort method", "start": 6698.52, "duration": 4.0 }, { "text": "clearly takes one argument from the", "start": 6700.639, "duration": 4.96 }, { "text": "programmer me namely the student's name", "start": 6702.52, "duration": 4.639 }, { "text": "and again we've seen this dichotomy", "start": 6705.599, "duration": 3.921 }, { "text": "before even though I'm trying to pass in", "start": 6707.159, "duration": 4.801 }, { "text": "one argument when I Define the method", "start": 6709.52, "duration": 4.679 }, { "text": "it's got to take that many arguments", "start": 6711.96, "duration": 4.159 }, { "text": "plus one more self which is always going", "start": 6714.199, "duration": 3.96 }, { "text": "to be automatically passed in by python", "start": 6716.119, "duration": 5.12 }, { "text": "first all right what do I want to do", "start": 6718.159, "duration": 4.56 }, { "text": "well let's go ahead and do something", "start": 6721.239, "duration": 4.4 }, { "text": "like this uh print quote unquote or", "start": 6722.719, "duration": 5.841 }, { "text": "rather print this name how about quote", "start": 6725.639, "duration": 6.721 }, { "text": "unquote is in quote unquote some house", "start": 6728.56, "duration": 5.36 }, { "text": "I'm going to again use some placeholder", "start": 6732.36, "duration": 3.0 }, { "text": "code for myself because I'm not quite", "start": 6733.92, "duration": 3.44 }, { "text": "sure how to finish implementing this", "start": 6735.36, "duration": 4.08 }, { "text": "Sorting Hat but I think that's enough to", "start": 6737.36, "duration": 4.52 }, { "text": "just test where my code is at now let me", "start": 6739.44, "duration": 5.279 }, { "text": "go ahead and run python of hat. and hit", "start": 6741.88, "duration": 5.319 }, { "text": "enter and it looks like indeed Harry is", "start": 6744.719, "duration": 4.601 }, { "text": "in some house we're not done yet because", "start": 6747.199, "duration": 3.761 }, { "text": "it's clearly not doing anything", "start": 6749.32, "duration": 4.359 }, { "text": "interesting but it at least is running", "start": 6750.96, "duration": 5.44 }, { "text": "correctly with no errors well let's go", "start": 6753.679, "duration": 7.081 }, { "text": "ahead now and decide where uh what house", "start": 6756.4, "duration": 5.64 }, { "text": "Harry should actually be in by", "start": 6760.76, "duration": 2.72 }, { "text": "introducing a bit of Randomness and", "start": 6762.04, "duration": 4.159 }, { "text": "choosing a house randomly well I can do", "start": 6763.48, "duration": 4.4 }, { "text": "this in a few ways let me go ahead and", "start": 6766.199, "duration": 4.641 }, { "text": "do this I need to have a list of houses", "start": 6767.88, "duration": 5.08 }, { "text": "somewhere so where can I put that I", "start": 6770.84, "duration": 3.359 }, { "text": "could solve this problem in different", "start": 6772.96, "duration": 2.88 }, { "text": "ways let me propose that I do this let", "start": 6774.199, "duration": 3.841 }, { "text": "me Define a method called init as I've", "start": 6775.84, "duration": 4.319 }, { "text": "done before that takes in self but no", "start": 6778.04, "duration": 4.28 }, { "text": "other arguments and whenever the Sorting", "start": 6780.159, "duration": 4.56 }, { "text": "Hat is instantiated let's do this let's", "start": 6782.32, "duration": 5.919 }, { "text": "create a houses instance variable plural", "start": 6784.719, "duration": 7.4 }, { "text": "that equals this list Gryffindor comma", "start": 6788.239, "duration": 7.92 }, { "text": "Hufflepuff comma uh Ravenclaw comma", "start": 6792.119, "duration": 6.04 }, { "text": "Slytherin so the exact same list that", "start": 6796.159, "duration": 4.401 }, { "text": "we've used before and I'm storing it in", "start": 6798.159, "duration": 4.48 }, { "text": "an instance variable inside of this", "start": 6800.56, "duration": 4.519 }, { "text": "class I'm not taking any arguments", "start": 6802.639, "duration": 5.161 }, { "text": "Beyond self in it but I just need this", "start": 6805.079, "duration": 5.681 }, { "text": "list of values somewhere for instance so", "start": 6807.8, "duration": 5.24 }, { "text": "what can I do here well let me go ahead", "start": 6810.76, "duration": 5.12 }, { "text": "and replace some house with the actual", "start": 6813.04, "duration": 4.72 }, { "text": "house well what could I do here well I", "start": 6815.88, "duration": 4.08 }, { "text": "want to put a house there well let's go", "start": 6817.76, "duration": 4.359 }, { "text": "ahead and create a variable called house", "start": 6819.96, "duration": 3.56 }, { "text": "and if you think back to our discussion", "start": 6822.119, "duration": 4.321 }, { "text": "of libraries in the random module there", "start": 6823.52, "duration": 5.679 }, { "text": "is a function called choice that if you", "start": 6826.44, "duration": 6.36 }, { "text": "pass in in a list of choices like self.", "start": 6829.199, "duration": 6.081 }, { "text": "houses that will pick a random house out", "start": 6832.8, "duration": 4.68 }, { "text": "of those four and then on line seven I", "start": 6835.28, "duration": 4.2 }, { "text": "can pass it in if I want to tighten this", "start": 6837.48, "duration": 3.48 }, { "text": "up let me just go ahead and highlight", "start": 6839.48, "duration": 3.599 }, { "text": "that code get rid of the variable it's", "start": 6840.96, "duration": 4.08 }, { "text": "technically unnecessary and because the", "start": 6843.079, "duration": 3.681 }, { "text": "line of code is still pretty short I'm", "start": 6845.04, "duration": 3.88 }, { "text": "okay with just putting it all in one", "start": 6846.76, "duration": 4.0 }, { "text": "line but I could certainly use the", "start": 6848.92, "duration": 4.199 }, { "text": "variable like I did a moment ago so what", "start": 6850.76, "duration": 5.8 }, { "text": "have I done in my init function I have", "start": 6853.119, "duration": 7.6 }, { "text": "defined a initialization of the object", "start": 6856.56, "duration": 6.159 }, { "text": "that stores in self do houses the list", "start": 6860.719, "duration": 4.4 }, { "text": "of four houses and then in sort I'm", "start": 6862.719, "duration": 4.201 }, { "text": "accessing that same list but I'm", "start": 6865.119, "duration": 4.361 }, { "text": "randomly choosing the set of houses", "start": 6866.92, "duration": 4.759 }, { "text": "there now why have I done it in this way", "start": 6869.48, "duration": 4.639 }, { "text": "this too is General convention anytime", "start": 6871.679, "duration": 4.201 }, { "text": "you have a list of things that who knows", "start": 6874.119, "duration": 4.401 }, { "text": "maybe will change over time places like", "start": 6875.88, "duration": 5.0 }, { "text": "Harvard have constructed new houses over", "start": 6878.52, "duration": 3.719 }, { "text": "the years so you might have to change", "start": 6880.88, "duration": 3.359 }, { "text": "the list of available houses it didn't", "start": 6882.239, "duration": 4.041 }, { "text": "happen in seven books or eight films of", "start": 6884.239, "duration": 3.721 }, { "text": "Harry Potter but you could imagine maybe", "start": 6886.28, "duration": 3.919 }, { "text": "Hogwarts eventually has a fifth house so", "start": 6887.96, "duration": 4.88 }, { "text": "there's generally some value in putting", "start": 6890.199, "duration": 5.04 }, { "text": "list of constants toward the top of your", "start": 6892.84, "duration": 4.12 }, { "text": "file toward the top of the class so it's", "start": 6895.239, "duration": 4.44 }, { "text": "just obvious what the list of values is", "start": 6896.96, "duration": 4.119 }, { "text": "you don't want to necessarily tuck it", "start": 6899.679, "duration": 3.96 }, { "text": "away in some function like sort", "start": 6901.079, "duration": 4.0 }, { "text": "especially if you might want to use that", "start": 6903.639, "duration": 3.761 }, { "text": "function in sorry especially if you want", "start": 6905.079, "duration": 4.721 }, { "text": "to use that list in multiple functions", "start": 6907.4, "duration": 4.0 }, { "text": "not just sort but if I kept adding to", "start": 6909.8, "duration": 3.08 }, { "text": "this class you might want to use that", "start": 6911.4, "duration": 2.96 }, { "text": "same list of houses in multiple", "start": 6912.88, "duration": 4.08 }, { "text": "functions so let's keep it in the object", "start": 6914.36, "duration": 6.319 }, { "text": "Itself by storing it in self. house is", "start": 6916.96, "duration": 5.199 }, { "text": "all right well we're about to change the", "start": 6920.679, "duration": 3.321 }, { "text": "course of history here perhaps let me do", "start": 6922.159, "duration": 4.361 }, { "text": "python of haty and I think we're about", "start": 6924.0, "duration": 4.84 }, { "text": "to assign Harry to one of those four", "start": 6926.52, "duration": 3.44 }, { "text": "houses", "start": 6928.84, "duration": 5.16 }, { "text": "randomly huh name error name random is", "start": 6929.96, "duration": 6.56 }, { "text": "not defined well wait a minute where did", "start": 6934.0, "duration": 5.32 }, { "text": "I go wrong here thinking back to our", "start": 6936.52, "duration": 5.599 }, { "text": "class on libraries why did my code break", "start": 6939.32, "duration": 6.279 }, { "text": "and not tell me where Harry is to be you", "start": 6942.119, "duration": 7.56 }, { "text": "do not import the random Library exactly", "start": 6945.599, "duration": 5.721 }, { "text": "the random library or module was", "start": 6949.679, "duration": 3.641 }, { "text": "something I want to use I need to tell", "start": 6951.32, "duration": 4.24 }, { "text": "python that at the top of my file so let", "start": 6953.32, "duration": 5.6 }, { "text": "me go up here and do import uh random", "start": 6955.56, "duration": 4.96 }, { "text": "and then below that let me go ahead and", "start": 6958.92, "duration": 3.44 }, { "text": "clear my terminal window and try again", "start": 6960.52, "duration": 4.719 }, { "text": "python of hatp crossing my fingers", "start": 6962.36, "duration": 5.799 }, { "text": "seeing where Harry is going to end up", "start": 6965.239, "duration": 5.84 }, { "text": "and okay Harry as of now is officially", "start": 6968.159, "duration": 4.92 }, { "text": "in Hufflepuff despite everything you've", "start": 6971.079, "duration": 4.481 }, { "text": "read or scene well let's run this again", "start": 6973.079, "duration": 4.241 }, { "text": "let me clear my window and run python of", "start": 6975.56, "duration": 4.36 }, { "text": "haty and now he's in Ravenclaw that's", "start": 6977.32, "duration": 4.6 }, { "text": "consistent with using random let's clear", "start": 6979.92, "duration": 3.92 }, { "text": "that and run it again he's still in", "start": 6981.92, "duration": 3.52 }, { "text": "Ravenclaw but that could happen even", "start": 6983.84, "duration": 3.04 }, { "text": "though there's four choices let's do it", "start": 6985.44, "duration": 3.759 }, { "text": "again Hufflepuff back in Hufflepuff we", "start": 6986.88, "duration": 4.04 }, { "text": "can't seem to get the right answer so to", "start": 6989.199, "duration": 4.44 }, { "text": "speak now he's in Gryffindor albeit", "start": 6990.92, "duration": 4.84 }, { "text": "randomly so we seem to have a program", "start": 6993.639, "duration": 3.681 }, { "text": "that based on these limited tests seems", "start": 6995.76, "duration": 4.52 }, { "text": "to indeed be assigning Harry to a house", "start": 6997.32, "duration": 5.2 }, { "text": "randomly now I'm somewhat lazily just", "start": 7000.28, "duration": 5.08 }, { "text": "letting sort print out this value I", "start": 7002.52, "duration": 4.679 }, { "text": "could do something else like return a", "start": 7005.36, "duration": 5.359 }, { "text": "string and then let me online 13 do the", "start": 7007.199, "duration": 6.161 }, { "text": "printing for me but for now I think we", "start": 7010.719, "duration": 5.92 }, { "text": "have an example of a class called hat", "start": 7013.36, "duration": 4.92 }, { "text": "that nonetheless applies some of our", "start": 7016.639, "duration": 3.48 }, { "text": "lessons learned thus far today where", "start": 7018.28, "duration": 3.72 }, { "text": "I've created a class because a Sorting", "start": 7020.119, "duration": 4.401 }, { "text": "Hat is frankly well a I was about to say", "start": 7022.0, "duration": 4.599 }, { "text": "real world entity but really a fantasy", "start": 7024.52, "duration": 4.719 }, { "text": "world entity and indeed that's a perhaps", "start": 7026.599, "duration": 5.321 }, { "text": "common heuristic or mental model to have", "start": 7029.239, "duration": 5.44 }, { "text": "when should you use a class to represent", "start": 7031.92, "duration": 5.04 }, { "text": "something in your code very often when", "start": 7034.679, "duration": 4.44 }, { "text": "you're trying to represent some real", "start": 7036.96, "duration": 5.0 }, { "text": "world World entity or fantasy world", "start": 7039.119, "duration": 5.321 }, { "text": "entity like a student which is something", "start": 7041.96, "duration": 5.32 }, { "text": "in the real world like a Sorting Hat", "start": 7044.44, "duration": 4.44 }, { "text": "which okay doesn't exist but hats", "start": 7047.28, "duration": 3.48 }, { "text": "certainly do so quite reasonable to have", "start": 7048.88, "duration": 4.16 }, { "text": "a class for hat and that's not always", "start": 7050.76, "duration": 4.24 }, { "text": "the case that classes represent real", "start": 7053.04, "duration": 5.28 }, { "text": "world entities but indeed we've seen", "start": 7055.0, "duration": 6.28 }, { "text": "thus far that int and stir and list and", "start": 7058.32, "duration": 5.2 }, { "text": "dict these are all structures that you", "start": 7061.28, "duration": 3.48 }, { "text": "might have in the real world we have", "start": 7063.52, "duration": 3.24 }, { "text": "integers and strings of text and other", "start": 7064.76, "duration": 3.72 }, { "text": "things so it rather makes sense to", "start": 7066.76, "duration": 3.2 }, { "text": "represent even those things more", "start": 7068.48, "duration": 4.239 }, { "text": "technically using a class as well you", "start": 7069.96, "duration": 4.88 }, { "text": "could use just a dictionary to represent", "start": 7072.719, "duration": 4.241 }, { "text": "a student or a hat but again with", "start": 7074.84, "duration": 5.08 }, { "text": "classes come all this and even more", "start": 7076.96, "duration": 5.759 }, { "text": "functionality but I honestly am not", "start": 7079.92, "duration": 5.88 }, { "text": "using classes in really the the right", "start": 7082.719, "duration": 6.281 }, { "text": "way here why well in the World of Harry", "start": 7085.8, "duration": 4.879 }, { "text": "Potter there really is only to my", "start": 7089.0, "duration": 4.76 }, { "text": "knowledge one Sorting Hat and yet here I", "start": 7090.679, "duration": 5.361 }, { "text": "have gone and implemented a class called", "start": 7093.76, "duration": 5.04 }, { "text": "hat and again a class is like a", "start": 7096.04, "duration": 5.48 }, { "text": "blueprint a template a mold that allows", "start": 7098.8, "duration": 5.16 }, { "text": "you to create one or more objects", "start": 7101.52, "duration": 4.44 }, { "text": "thereof now most of my programs thus far", "start": 7103.96, "duration": 3.4 }, { "text": "have been pretty simple and I've just", "start": 7105.96, "duration": 3.44 }, { "text": "created one student but certainly if I", "start": 7107.36, "duration": 3.759 }, { "text": "spent more time and wrote more code you", "start": 7109.4, "duration": 4.04 }, { "text": "could imagine writing one program that", "start": 7111.119, "duration": 4.361 }, { "text": "has a list of students many more", "start": 7113.44, "duration": 4.32 }, { "text": "students than just the one we keep", "start": 7115.48, "duration": 4.4 }, { "text": "demonstrating yet it would be a little", "start": 7117.76, "duration": 4.08 }, { "text": "weird it's a little inconsistent with", "start": 7119.88, "duration": 3.839 }, { "text": "the real or the Fantasy World of Harry", "start": 7121.84, "duration": 4.64 }, { "text": "Potter to instantiate one two three or", "start": 7123.719, "duration": 5.161 }, { "text": "more sorting hats there really is just", "start": 7126.48, "duration": 4.92 }, { "text": "one really one Singleton if you will", "start": 7128.88, "duration": 3.96 }, { "text": "which is a term of Art in a lot of", "start": 7131.4, "duration": 3.92 }, { "text": "context of programming so let me propose", "start": 7132.84, "duration": 4.2 }, { "text": "that we actually improve the design of", "start": 7135.32, "duration": 3.96 }, { "text": "the Sorting Hat so that we don't have to", "start": 7137.04, "duration": 5.159 }, { "text": "instantiate a Sorting Hat because right", "start": 7139.28, "duration": 5.0 }, { "text": "now this is kind of allowing me to do", "start": 7142.199, "duration": 4.4 }, { "text": "something like hat one equals hat hat", "start": 7144.28, "duration": 4.68 }, { "text": "two equals hat hat three equals and so", "start": 7146.599, "duration": 3.841 }, { "text": "forth I don't really need that", "start": 7148.96, "duration": 3.759 }, { "text": "capability I really just need to", "start": 7150.44, "duration": 4.799 }, { "text": "represent the Sorting Hat with a class", "start": 7152.719, "duration": 4.281 }, { "text": "but I don't really need to instantiate", "start": 7155.239, "duration": 3.4 }, { "text": "it why because it already exists I need", "start": 7157.0, "duration": 5.199 }, { "text": "just one so it turns out in Python that", "start": 7158.639, "duration": 5.201 }, { "text": "up until now we've been using as I keep", "start": 7162.199, "duration": 4.081 }, { "text": "calling them instance methods writing", "start": 7163.84, "duration": 4.72 }, { "text": "functions inside of classes that are", "start": 7166.28, "duration": 4.76 }, { "text": "automatically past a reference to self", "start": 7168.56, "duration": 4.519 }, { "text": "the current object but sometimes you", "start": 7171.04, "duration": 3.76 }, { "text": "just don't need that sometimes it", "start": 7173.079, "duration": 3.921 }, { "text": "suffices to just know what the class is", "start": 7174.8, "duration": 4.04 }, { "text": "and assume that there might not even be", "start": 7177.0, "duration": 4.28 }, { "text": "any objects of that class so in this", "start": 7178.84, "duration": 4.879 }, { "text": "sense you can use a class really is a", "start": 7181.28, "duration": 5.52 }, { "text": "container for data Andor functionality", "start": 7183.719, "duration": 5.641 }, { "text": "that is just somehow conceptually", "start": 7186.8, "duration": 6.0 }, { "text": "related things related to assorting hats", "start": 7189.36, "duration": 5.0 }, { "text": "and there's this other decorator or", "start": 7192.8, "duration": 3.72 }, { "text": "function called class method that allows", "start": 7194.36, "duration": 3.96 }, { "text": "us to do just this so let me go back to", "start": 7196.52, "duration": 4.8 }, { "text": "my code here and let me propose that if", "start": 7198.32, "duration": 5.839 }, { "text": "I'm not going to instantiate multiple", "start": 7201.32, "duration": 5.359 }, { "text": "houses I don't really need this init", "start": 7204.159, "duration": 3.96 }, { "text": "method because that's really meant to", "start": 7206.679, "duration": 4.121 }, { "text": "initialize specific objects from that", "start": 7208.119, "duration": 5.281 }, { "text": "blueprint that template that mold so let", "start": 7210.8, "duration": 4.72 }, { "text": "me get rid of this but if I get rid of", "start": 7213.4, "duration": 4.52 }, { "text": "this I no longer have access to self but", "start": 7215.52, "duration": 4.719 }, { "text": "that's okay because it turns out in", "start": 7217.92, "duration": 5.36 }, { "text": "addition to their existing class methods", "start": 7220.239, "duration": 5.201 }, { "text": "there are also what we might call class", "start": 7223.28, "duration": 5.6 }, { "text": "variables and class variables exist", "start": 7225.44, "duration": 6.0 }, { "text": "within the class itself and there's just", "start": 7228.88, "duration": 5.799 }, { "text": "one copy of that variable for all of the", "start": 7231.44, "duration": 5.4 }, { "text": "objects thereof they all share if you", "start": 7234.679, "duration": 4.96 }, { "text": "will the same variable be it an INT or", "start": 7236.84, "duration": 5.239 }, { "text": "stir or in this case a list so what I've", "start": 7239.639, "duration": 6.201 }, { "text": "done here is Define inside of my hat", "start": 7242.079, "duration": 8.12 }, { "text": "class in a class variable called houses", "start": 7245.84, "duration": 6.359 }, { "text": "I don't say self because self is no", "start": 7250.199, "duration": 3.88 }, { "text": "longer relevant self refers to specific", "start": 7252.199, "duration": 4.761 }, { "text": "objects I want a variable inside of this", "start": 7254.079, "duration": 5.761 }, { "text": "class AKA a class variable that equals", "start": 7256.96, "duration": 5.119 }, { "text": "that list because it's inside of this", "start": 7259.84, "duration": 6.359 }, { "text": "hat now class I can use that list in any", "start": 7262.079, "duration": 5.961 }, { "text": "of my functions I've only got one now", "start": 7266.199, "duration": 3.721 }, { "text": "called sort but if I had more it would", "start": 7268.04, "duration": 3.76 }, { "text": "be accessible to all of those methods as", "start": 7269.92, "duration": 4.759 }, { "text": "well and with sort it also doesn't", "start": 7271.8, "duration": 5.319 }, { "text": "really make sense to sort within a", "start": 7274.679, "duration": 4.0 }, { "text": "specific sorting hack because again", "start": 7277.119, "duration": 3.761 }, { "text": "there only want there to be one so I can", "start": 7278.679, "duration": 4.44 }, { "text": "actually specify that this is a class", "start": 7280.88, "duration": 5.239 }, { "text": "method by saying at class method and I", "start": 7283.119, "duration": 5.681 }, { "text": "don't pass in self anymore I actually by", "start": 7286.119, "duration": 5.321 }, { "text": "convention pass in the a reference to", "start": 7288.8, "duration": 5.319 }, { "text": "the class itself it's typically written", "start": 7291.44, "duration": 7.239 }, { "text": "as CLS why well if you wrote C ass that", "start": 7294.119, "duration": 6.681 }, { "text": "would actually conflict with the keyword", "start": 7298.679, "duration": 4.48 }, { "text": "class that we keep using up here so the", "start": 7300.8, "duration": 4.56 }, { "text": "world realized that oops we uh can't", "start": 7303.159, "duration": 4.201 }, { "text": "reuse that same phrase here so let's", "start": 7305.36, "duration": 4.319 }, { "text": "just call this class this this is useful", "start": 7307.36, "duration": 4.56 }, { "text": "in some context including this one why", "start": 7309.679, "duration": 4.96 }, { "text": "well notice what I can now do I can now", "start": 7311.92, "duration": 5.96 }, { "text": "change self to be just class why because", "start": 7314.639, "duration": 5.881 }, { "text": "house is now not an instance variable", "start": 7317.88, "duration": 5.44 }, { "text": "accessible via self. houses it is now a", "start": 7320.52, "duration": 6.0 }, { "text": "class variable accessible via class.", "start": 7323.32, "duration": 6.12 }, { "text": "houses or technically CLS do houses in", "start": 7326.52, "duration": 5.559 }, { "text": "this case but now the final flourish is", "start": 7329.44, "duration": 6.04 }, { "text": "this now I don't have to instantiate any", "start": 7332.079, "duration": 7.16 }, { "text": "hat objects as I used to on here line 13", "start": 7335.48, "duration": 6.0 }, { "text": "I can just use functionality that comes", "start": 7339.239, "duration": 4.201 }, { "text": "with this class so I'm going to delete", "start": 7341.48, "duration": 3.84 }, { "text": "that line Al together I'm going to", "start": 7343.44, "duration": 4.88 }, { "text": "capitalize the Hat on this new line 13", "start": 7345.32, "duration": 7.08 }, { "text": "and just say hat. sort quote unquote", "start": 7348.32, "duration": 6.759 }, { "text": "Harry so what have I done I've not", "start": 7352.4, "duration": 5.48 }, { "text": "bothered instantiating an object of type", "start": 7355.079, "duration": 6.281 }, { "text": "hat I am just accessing a class method", "start": 7357.88, "duration": 5.359 }, { "text": "inside of the Hat class that you know", "start": 7361.36, "duration": 4.48 }, { "text": "what is just G to work this is how class", "start": 7363.239, "duration": 4.241 }, { "text": "methods work you use the name of the", "start": 7365.84, "duration": 3.68 }, { "text": "class capital letter in all", "start": 7367.48, "duration": 4.8 }, { "text": "do method name passing in any arguments", "start": 7369.52, "duration": 4.48 }, { "text": "you want python is going to", "start": 7372.28, "duration": 4.359 }, { "text": "automatically pass in some variable via", "start": 7374.0, "duration": 5.639 }, { "text": "which you can refer to that class in", "start": 7376.639, "duration": 4.6 }, { "text": "that function that you've implemented", "start": 7379.639, "duration": 3.44 }, { "text": "inside of that class so that I can do", "start": 7381.239, "duration": 3.88 }, { "text": "something like this it's not that I want", "start": 7383.079, "duration": 4.12 }, { "text": "a variable called houses locally in this", "start": 7385.119, "duration": 3.681 }, { "text": "function I want the variable called", "start": 7387.199, "duration": 3.801 }, { "text": "houses that's associated with this", "start": 7388.8, "duration": 5.919 }, { "text": "current class so I can still access this", "start": 7391.0, "duration": 6.56 }, { "text": "same list that I defined on line six and", "start": 7394.719, "duration": 4.561 }, { "text": "now if I go back down here to my", "start": 7397.56, "duration": 4.92 }, { "text": "terminal and run python of hat. enter", "start": 7399.28, "duration": 5.52 }, { "text": "Harry is still in Hufflepuff once more", "start": 7402.48, "duration": 4.56 }, { "text": "Harry is still in Hufflepuff once more", "start": 7404.8, "duration": 5.48 }, { "text": "Harry is back in Gryffindor at least", "start": 7407.04, "duration": 6.639 }, { "text": "randomly questions now on these class", "start": 7410.28, "duration": 6.08 }, { "text": "variables or these class methods which", "start": 7413.679, "duration": 6.241 }, { "text": "are in contrast with instance variables", "start": 7416.36, "duration": 5.96 }, { "text": "and instance methods and the one thing", "start": 7419.92, "duration": 4.48 }, { "text": "at least that's a little strange here is", "start": 7422.32, "duration": 3.64 }, { "text": "that even though there's a decorator", "start": 7424.4, "duration": 4.159 }, { "text": "called at class method there is not one", "start": 7425.96, "duration": 5.96 }, { "text": "called at instance method a method is", "start": 7428.559, "duration": 5.801 }, { "text": "just automatically a so-called instant", "start": 7431.92, "duration": 4.799 }, { "text": "method when you define it without any", "start": 7434.36, "duration": 4.839 }, { "text": "decorator can you have a class inside", "start": 7436.719, "duration": 5.321 }, { "text": "another class you can you can Define one", "start": 7439.199, "duration": 5.201 }, { "text": "class inside of another generally", "start": 7442.04, "duration": 4.159 }, { "text": "speaking this isn't done but there are", "start": 7444.4, "duration": 3.799 }, { "text": "cases where it can be helpful especially", "start": 7446.199, "duration": 4.44 }, { "text": "for larger more sophisticated programs", "start": 7448.199, "duration": 5.601 }, { "text": "so yes it is possible good other", "start": 7450.639, "duration": 5.761 }, { "text": "questions the the question was about the", "start": 7453.8, "duration": 5.359 }, { "text": "self do houses when you when we remove", "start": 7456.4, "duration": 7.319 }, { "text": "it we uh and we pass data the variable", "start": 7459.159, "duration": 8.721 }, { "text": "is created itself why we remove the S so", "start": 7463.719, "duration": 6.601 }, { "text": "in the previous examples both of the Hat", "start": 7467.88, "duration": 4.16 }, { "text": "demonstration and also all of the", "start": 7470.32, "duration": 5.279 }, { "text": "student demonstrations we were uh", "start": 7472.04, "duration": 5.679 }, { "text": "creating a student object by calling", "start": 7475.599, "duration": 4.0 }, { "text": "student capital S open parenthesis", "start": 7477.719, "duration": 3.96 }, { "text": "closed parenthesis with eventually name", "start": 7479.599, "duration": 4.08 }, { "text": "and a house passed in and then we were", "start": 7481.679, "duration": 4.321 }, { "text": "using the d uh the Double underscore", "start": 7483.679, "duration": 5.721 }, { "text": "init method to initialize the self name", "start": 7486.0, "duration": 6.559 }, { "text": "and the self. housee instance variables", "start": 7489.4, "duration": 6.08 }, { "text": "therein to those respective values in", "start": 7492.559, "duration": 5.241 }, { "text": "this latest version of the Sorting Hat I", "start": 7495.48, "duration": 4.679 }, { "text": "haven't bothered with self anywhere only", "start": 7497.8, "duration": 5.0 }, { "text": "because conceptually I don't need or", "start": 7500.159, "duration": 4.801 }, { "text": "want there to be multiple hats in the", "start": 7502.8, "duration": 4.48 }, { "text": "world I'm just using the class as kind", "start": 7504.96, "duration": 5.279 }, { "text": "of a container to bundle up this list of", "start": 7507.28, "duration": 5.24 }, { "text": "houses this sorting functionality maybe", "start": 7510.239, "duration": 4.0 }, { "text": "eventually I'll add more functionality", "start": 7512.52, "duration": 4.52 }, { "text": "to it but that's it and so sometimes you", "start": 7514.239, "duration": 4.601 }, { "text": "can use objectoriented programming in", "start": 7517.04, "duration": 3.559 }, { "text": "this somewhat different way when you", "start": 7518.84, "duration": 3.879 }, { "text": "want there to be functionality but it's", "start": 7520.599, "duration": 4.56 }, { "text": "not specific to any one specific hat", "start": 7522.719, "duration": 5.601 }, { "text": "it's specific to the Sorting Hat", "start": 7525.159, "duration": 5.48 }, { "text": "itself how about one other question now", "start": 7528.32, "duration": 5.48 }, { "text": "on these class variables or methods just", "start": 7530.639, "duration": 5.04 }, { "text": "another way of using objectoriented", "start": 7533.8, "duration": 3.56 }, { "text": "programming but to solve somewhat", "start": 7535.679, "duration": 3.321 }, { "text": "different problem well what's the", "start": 7537.36, "duration": 4.839 }, { "text": "difference between the class hat and I", "start": 7539.0, "duration": 6.599 }, { "text": "don't know like a function of hat a good", "start": 7542.199, "duration": 5.081 }, { "text": "question so why are we using a class at", "start": 7545.599, "duration": 4.201 }, { "text": "all and not just having a file called", "start": 7547.28, "duration": 5.399 }, { "text": "hat. with a variable called houses and a", "start": 7549.8, "duration": 5.0 }, { "text": "function called sort like why are we", "start": 7552.679, "duration": 3.88 }, { "text": "adding this complexity in this", "start": 7554.8, "duration": 3.439 }, { "text": "particular case we don't necessarily", "start": 7556.559, "duration": 4.6 }, { "text": "need to I could absolutely go in here I", "start": 7558.239, "duration": 5.561 }, { "text": "could get rid of the class I could uh", "start": 7561.159, "duration": 5.241 }, { "text": "undo this indentation I could get rid of", "start": 7563.8, "duration": 4.839 }, { "text": "this decorator and I could get rid of", "start": 7566.4, "duration": 5.12 }, { "text": "hat Dot and I could just do this and", "start": 7568.639, "duration": 4.641 }, { "text": "additionally let's see let's get rid of", "start": 7571.52, "duration": 4.28 }, { "text": "class here let's get rid of class Here", "start": 7573.28, "duration": 5.68 }, { "text": "and Now run python of hat dopy enter and", "start": 7575.8, "duration": 4.839 }, { "text": "it still works put Harry in the wrong", "start": 7578.96, "duration": 3.44 }, { "text": "house but that's what we H what happens", "start": 7580.639, "duration": 4.201 }, { "text": "randomly that's fine too what we're", "start": 7582.4, "duration": 3.96 }, { "text": "introducing today by way of", "start": 7584.84, "duration": 3.279 }, { "text": "objectoriented programming is just a", "start": 7586.36, "duration": 4.0 }, { "text": "different way of modeling the world it's", "start": 7588.119, "duration": 4.161 }, { "text": "not really compelling with an example", "start": 7590.36, "duration": 3.879 }, { "text": "like this frankly that's relatively", "start": 7592.28, "duration": 4.12 }, { "text": "simple it's not very complex there's not", "start": 7594.239, "duration": 3.88 }, { "text": "much functionality honestly the version", "start": 7596.4, "duration": 3.64 }, { "text": "that we just typed up these 10 lines", "start": 7598.119, "duration": 3.921 }, { "text": "this is fine this solves this problem", "start": 7600.04, "duration": 4.519 }, { "text": "but as our code gets longer as we start", "start": 7602.04, "duration": 4.119 }, { "text": "collaborating with other people as the", "start": 7604.559, "duration": 2.801 }, { "text": "problems we're trying to solve with code", "start": 7606.159, "duration": 2.92 }, { "text": "get more sophisticated you're going to", "start": 7607.36, "duration": 4.839 }, { "text": "find that your code gets messy quickly", "start": 7609.079, "duration": 4.48 }, { "text": "and you're going to find that you have a", "start": 7612.199, "duration": 3.241 }, { "text": "huge number of functions for instance in", "start": 7613.559, "duration": 4.361 }, { "text": "one file and some of them are related to", "start": 7615.44, "duration": 4.759 }, { "text": "each other but some of them are not well", "start": 7617.92, "duration": 3.639 }, { "text": "at that point wouldn't it be nice to", "start": 7620.199, "duration": 3.121 }, { "text": "just organize them a little differently", "start": 7621.559, "duration": 3.481 }, { "text": "and in the World of Harry Potter let's", "start": 7623.32, "duration": 3.48 }, { "text": "have a class for student let's have a", "start": 7625.04, "duration": 3.599 }, { "text": "class for Professor let's have a class", "start": 7626.8, "duration": 3.72 }, { "text": "for the Sorting Hat let's have a class", "start": 7628.639, "duration": 3.681 }, { "text": "for something else and so once your", "start": 7630.52, "duration": 3.719 }, { "text": "world gets much more complicated than", "start": 7632.32, "duration": 4.08 }, { "text": "some of the demonstrations we do here in", "start": 7634.239, "duration": 3.48 }, { "text": "class when we want to focus on", "start": 7636.4, "duration": 3.759 }, { "text": "individual ideas is object-oriented", "start": 7637.719, "duration": 4.041 }, { "text": "programming is just a way of", "start": 7640.159, "duration": 4.241 }, { "text": "encapsulating related data that is", "start": 7641.76, "duration": 4.839 }, { "text": "variables related functionality that is", "start": 7644.4, "duration": 5.08 }, { "text": "methods inside of things that have names", "start": 7646.599, "duration": 5.08 }, { "text": "these things are called classes so it's", "start": 7649.48, "duration": 4.239 }, { "text": "just another way to solve problems and", "start": 7651.679, "duration": 3.721 }, { "text": "when we focused on libraries a couple of", "start": 7653.719, "duration": 3.761 }, { "text": "weeks back that too was another solution", "start": 7655.4, "duration": 3.839 }, { "text": "to the same problem you could Define", "start": 7657.48, "duration": 4.119 }, { "text": "your own modules or packages put some of", "start": 7659.239, "duration": 4.281 }, { "text": "your data Andor functionality in there", "start": 7661.599, "duration": 4.361 }, { "text": "and that's fine too and sometimes which", "start": 7663.52, "duration": 4.52 }, { "text": "one you should use overlaps if you're", "start": 7665.96, "duration": 4.04 }, { "text": "familiar with ven diagrams the", "start": 7668.04, "duration": 4.119 }, { "text": "overlapping region might mean that you", "start": 7670.0, "duration": 4.0 }, { "text": "could use a class you could use a module", "start": 7672.159, "duration": 3.52 }, { "text": "or a package you could just use a single", "start": 7674.0, "duration": 4.8 }, { "text": "local file over time you'll develop an", "start": 7675.679, "duration": 4.56 }, { "text": "instinct and maybe even a personal", "start": 7678.8, "duration": 4.399 }, { "text": "preference for which tool to", "start": 7680.239, "duration": 6.121 }, { "text": "use all right let me propose now that we", "start": 7683.199, "duration": 5.04 }, { "text": "apply this same idea of a class method", "start": 7686.36, "duration": 4.359 }, { "text": "to clean up one other thing as well let", "start": 7688.239, "duration": 6.48 }, { "text": "me close haty and reopen student. py as", "start": 7690.719, "duration": 5.96 }, { "text": "we left it earlier and let me go ahead", "start": 7694.719, "duration": 4.48 }, { "text": "and simplify it just a little bit", "start": 7696.679, "duration": 4.841 }, { "text": "uh I'm going to go ahead and get rid of", "start": 7699.199, "duration": 4.4 }, { "text": "the properties not because there's", "start": 7701.52, "duration": 3.28 }, { "text": "anything wrong with them but just", "start": 7703.599, "duration": 2.6 }, { "text": "because I want us to focus on some of", "start": 7704.8, "duration": 3.64 }, { "text": "the key ideas when we began with this", "start": 7706.199, "duration": 3.96 }, { "text": "program so I'm going to go ahead and", "start": 7708.44, "duration": 3.6 }, { "text": "keep Maine as well I'm not going to", "start": 7710.159, "duration": 4.321 }, { "text": "adversar try to change Harry's uh", "start": 7712.04, "duration": 4.599 }, { "text": "address there I'm going to instead go", "start": 7714.48, "duration": 4.119 }, { "text": "ahead though and just print the student", "start": 7716.639, "duration": 4.161 }, { "text": "but this is the thing I want to focus on", "start": 7718.599, "duration": 4.921 }, { "text": "here this in our previous student", "start": 7720.8, "duration": 4.839 }, { "text": "examples was kind of a missed", "start": 7723.52, "duration": 4.679 }, { "text": "opportunity to clean up my code well", "start": 7725.639, "duration": 4.44 }, { "text": "what what do I mean by that well up here", "start": 7728.199, "duration": 3.641 }, { "text": "at the top of this file even though I've", "start": 7730.079, "duration": 3.201 }, { "text": "simplified it by getting rid of the", "start": 7731.84, "duration": 2.64 }, { "text": "properties and all of that error", "start": 7733.28, "duration": 2.48 }, { "text": "checking because I want to focus on the", "start": 7734.48, "duration": 3.28 }, { "text": "essence of this class now just the", "start": 7735.76, "duration": 3.56 }, { "text": "students name and the house and the", "start": 7737.76, "duration": 4.839 }, { "text": "printing thereof this is by nature of", "start": 7739.32, "duration": 5.72 }, { "text": "classes an object-oriented programming", "start": 7742.599, "duration": 6.08 }, { "text": "theoretically all of my student specific", "start": 7745.04, "duration": 6.079 }, { "text": "functionality that is to say if I have", "start": 7748.679, "duration": 4.241 }, { "text": "functionality and data related to a", "start": 7751.119, "duration": 4.56 }, { "text": "student you the programmer my colleague", "start": 7752.92, "duration": 4.719 }, { "text": "would assume that it's all bundled up", "start": 7755.679, "duration": 3.96 }, { "text": "encapsulated so to speak inside of the", "start": 7757.639, "duration": 4.44 }, { "text": "student class and yet if you scroll down", "start": 7759.639, "duration": 4.721 }, { "text": "further what is this like there's a", "start": 7762.079, "duration": 4.241 }, { "text": "function called get student that just", "start": 7764.36, "duration": 4.04 }, { "text": "exists elsewhere in this file that", "start": 7766.32, "duration": 3.839 }, { "text": "prompts the user for a name prompts the", "start": 7768.4, "duration": 3.64 }, { "text": "user for a house creates the student", "start": 7770.159, "duration": 3.92 }, { "text": "object and then returns it like that's", "start": 7772.04, "duration": 5.0 }, { "text": "not wrong like it works and we saw many", "start": 7774.079, "duration": 5.52 }, { "text": "many times it kept working but this is a", "start": 7777.04, "duration": 4.88 }, { "text": "little weird right because what if this", "start": 7779.599, "duration": 4.921 }, { "text": "is a function that helps you get a", "start": 7781.92, "duration": 4.48 }, { "text": "student helps you get the name of a", "start": 7784.52, "duration": 3.84 }, { "text": "student and the house of a student why", "start": 7786.4, "duration": 3.6 }, { "text": "why isn't that functionality in the", "start": 7788.36, "duration": 3.68 }, { "text": "class itself after all as my code gets", "start": 7790.0, "duration": 3.719 }, { "text": "more and more complicated and does more", "start": 7792.04, "duration": 3.159 }, { "text": "things I'm going to be looking at the", "start": 7793.719, "duration": 3.281 }, { "text": "student class for all student related", "start": 7795.199, "duration": 3.081 }, { "text": "functionality I'm not going to be", "start": 7797.0, "duration": 3.239 }, { "text": "scrolling down expecting that oh maybe", "start": 7798.28, "duration": 3.839 }, { "text": "there's some other student functionality", "start": 7800.239, "duration": 4.4 }, { "text": "just kind of randomly later in this file", "start": 7802.119, "duration": 4.641 }, { "text": "so it's not wrong but this is again", "start": 7804.639, "duration": 5.56 }, { "text": "evidence of maybe bad design not so much", "start": 7806.76, "duration": 5.959 }, { "text": "with this small program but this is an", "start": 7810.199, "duration": 4.081 }, { "text": "example again of code smell like", "start": 7812.719, "duration": 3.121 }, { "text": "something smells a little off here like", "start": 7814.28, "duration": 2.76 }, { "text": "this is probably going to get us in", "start": 7815.84, "duration": 4.0 }, { "text": "trouble by separating related", "start": 7817.04, "duration": 4.679 }, { "text": "functionality so again it's a design", "start": 7819.84, "duration": 4.96 }, { "text": "principle not a correctness concern but", "start": 7821.719, "duration": 5.48 }, { "text": "class methods allow us to address this", "start": 7824.8, "duration": 4.839 }, { "text": "too let me go ahead and do this I'm", "start": 7827.199, "duration": 4.201 }, { "text": "going to delete get student alog", "start": 7829.639, "duration": 4.801 }, { "text": "together leaving only main as my other", "start": 7831.4, "duration": 5.48 }, { "text": "function here and inside of my student", "start": 7834.44, "duration": 4.759 }, { "text": "class I'm going to do this I'm going to", "start": 7836.88, "duration": 4.44 }, { "text": "define a function even more simply", "start": 7839.199, "duration": 5.081 }, { "text": "called get and by nature of how class", "start": 7841.32, "duration": 4.72 }, { "text": "methods work it's going to take in the", "start": 7844.28, "duration": 3.799 }, { "text": "name of the class itself or reference", "start": 7846.04, "duration": 4.159 }, { "text": "there too as an argument and I'm going", "start": 7848.079, "duration": 3.721 }, { "text": "to move the functionality from get", "start": 7850.199, "duration": 3.4 }, { "text": "student into the student class and I'm", "start": 7851.8, "duration": 4.68 }, { "text": "going to do this name equals input quote", "start": 7853.599, "duration": 6.161 }, { "text": "unquote name uh house equals input quote", "start": 7856.48, "duration": 6.52 }, { "text": "unquote house and then what this", "start": 7859.76, "duration": 7.08 }, { "text": "function is going to do is return a new", "start": 7863.0, "duration": 7.119 }, { "text": "student object by calling class which", "start": 7866.84, "duration": 6.04 }, { "text": "again is just an automatically passed in", "start": 7870.119, "duration": 5.801 }, { "text": "reference to the class itself passing in", "start": 7872.88, "duration": 6.199 }, { "text": "name and house and I will admit this", "start": 7875.92, "duration": 5.48 }, { "text": "syntax seems a little strange that now", "start": 7879.079, "duration": 4.721 }, { "text": "I'm calling CLS and I'm passing in these", "start": 7881.4, "duration": 4.12 }, { "text": "arguments but let me do one final fix", "start": 7883.8, "duration": 3.399 }, { "text": "here let me go to the top of this", "start": 7885.52, "duration": 3.88 }, { "text": "function and more explicitly say this is", "start": 7887.199, "duration": 5.161 }, { "text": "a class method this solves a potential", "start": 7889.4, "duration": 4.92 }, { "text": "chicken in the egg problem so to speak", "start": 7892.36, "duration": 4.0 }, { "text": "whereby one needs to come before the", "start": 7894.32, "duration": 4.16 }, { "text": "other potentially so what am I doing", "start": 7896.36, "duration": 5.279 }, { "text": "here inside of my student class I now", "start": 7898.48, "duration": 6.36 }, { "text": "have a function called get it is I shall", "start": 7901.639, "duration": 5.6 }, { "text": "claim a class method what does that mean", "start": 7904.84, "duration": 5.399 }, { "text": "it just means I can call this method", "start": 7907.239, "duration": 6.121 }, { "text": "without instantiating a student object", "start": 7910.239, "duration": 5.44 }, { "text": "first there in lies the potential", "start": 7913.36, "duration": 4.08 }, { "text": "Chicken and the Egg problem and if", "start": 7915.679, "duration": 3.48 }, { "text": "unfamiliar that's an expression meaning", "start": 7917.44, "duration": 3.92 }, { "text": "well did the world have chickens first", "start": 7919.159, "duration": 4.201 }, { "text": "that laid eggs or was there an egg that", "start": 7921.36, "duration": 4.56 }, { "text": "then Bor uh yielded the chickens but how", "start": 7923.36, "duration": 4.08 }, { "text": "did the egg get there it's this sort of", "start": 7925.92, "duration": 3.04 }, { "text": "weird circular problem and that's what", "start": 7927.44, "duration": 4.159 }, { "text": "we're facing here it would be weird if", "start": 7928.96, "duration": 5.84 }, { "text": "you had to create a student object in", "start": 7931.599, "duration": 6.08 }, { "text": "order to call get in order to get", "start": 7934.8, "duration": 5.319 }, { "text": "another student object like that sounds", "start": 7937.679, "duration": 6.241 }, { "text": "messy let's just get a student via a", "start": 7940.119, "duration": 6.281 }, { "text": "class method that by definition does not", "start": 7943.92, "duration": 4.679 }, { "text": "require you to create a student object", "start": 7946.4, "duration": 4.159 }, { "text": "first just like the Hat in its final", "start": 7948.599, "duration": 5.241 }, { "text": "form we use the Hat class to just say", "start": 7950.559, "duration": 5.761 }, { "text": "hat Capital h.s sort we didn't need to", "start": 7953.84, "duration": 4.2 }, { "text": "create a hat first we just used the", "start": 7956.32, "duration": 4.279 }, { "text": "class itself so what am I going to do", "start": 7958.04, "duration": 5.199 }, { "text": "here now let me go down to Main and", "start": 7960.599, "duration": 4.921 }, { "text": "instead of saying get student notice", "start": 7963.239, "duration": 5.92 }, { "text": "what I can now do student. get and", "start": 7965.52, "duration": 6.44 }, { "text": "everything else can stay the same all", "start": 7969.159, "duration": 5.641 }, { "text": "I've done now is I've migrated all of my", "start": 7971.96, "duration": 4.84 }, { "text": "logic from get student which was this", "start": 7974.8, "duration": 4.319 }, { "text": "own Standalone function but clearly", "start": 7976.8, "duration": 5.08 }, { "text": "related to students by name I've moved", "start": 7979.119, "duration": 6.52 }, { "text": "the same code really to inside of the", "start": 7981.88, "duration": 6.319 }, { "text": "student class in a more simply named", "start": 7985.639, "duration": 4.201 }, { "text": "function called get but I could still", "start": 7988.199, "duration": 3.321 }, { "text": "call it get student if I want it just", "start": 7989.84, "duration": 3.48 }, { "text": "sees a little redundant to call it get", "start": 7991.52, "duration": 3.599 }, { "text": "student in a student class so I'm", "start": 7993.32, "duration": 4.16 }, { "text": "simplifying so I have a method called", "start": 7995.119, "duration": 5.12 }, { "text": "get but I'm calling it a class method to", "start": 7997.48, "duration": 4.88 }, { "text": "avoid that chicken in the egg problem I", "start": 8000.239, "duration": 4.88 }, { "text": "want to be able to call get without", "start": 8002.36, "duration": 5.52 }, { "text": "having a student object in my universe", "start": 8005.119, "duration": 5.881 }, { "text": "already and the Syntax for that is at", "start": 8007.88, "duration": 5.679 }, { "text": "class method the convention is to give", "start": 8011.0, "duration": 4.36 }, { "text": "this method at least one argument by", "start": 8013.559, "duration": 4.281 }, { "text": "convention called CLS for class which is", "start": 8015.36, "duration": 3.6 }, { "text": "just going to be a reference to the", "start": 8017.84, "duration": 3.719 }, { "text": "class itself lines 11 and 12 are", "start": 8018.96, "duration": 4.36 }, { "text": "identical to what they've always been", "start": 8021.559, "duration": 4.401 }, { "text": "and get student the only new syntax here", "start": 8023.32, "duration": 4.68 }, { "text": "is this but this again is one of the", "start": 8025.96, "duration": 4.52 }, { "text": "features of object-oriented programming", "start": 8028.0, "duration": 4.32 }, { "text": "you can now", "start": 8030.48, "duration": 5.04 }, { "text": "instantiate a student object by just", "start": 8032.32, "duration": 6.279 }, { "text": "using CLS that's passed in I technically", "start": 8035.52, "duration": 5.36 }, { "text": "could use student capital S but it turns", "start": 8038.599, "duration": 4.12 }, { "text": "out I'm doing what's more conventional", "start": 8040.88, "duration": 3.759 }, { "text": "because this will both solve and avoid", "start": 8042.719, "duration": 3.4 }, { "text": "problems down the line with more", "start": 8044.639, "duration": 4.0 }, { "text": "complicated code this line here on line", "start": 8046.119, "duration": 5.08 }, { "text": "13 just means create an object of the", "start": 8048.639, "duration": 4.04 }, { "text": "current class what class is that well", "start": 8051.199, "duration": 3.52 }, { "text": "whatever CLS is well that by definition", "start": 8052.679, "duration": 4.04 }, { "text": "of how it all works is going to be", "start": 8054.719, "duration": 4.36 }, { "text": "student and I want you to initialize it", "start": 8056.719, "duration": 6.48 }, { "text": "as always with name and house so now", "start": 8059.079, "duration": 7.0 }, { "text": "scrolling down my code is this and this", "start": 8063.199, "duration": 5.241 }, { "text": "is just nice to read you did perhaps", "start": 8066.079, "duration": 4.441 }, { "text": "have to acquire a taste for this and I", "start": 8068.44, "duration": 3.719 }, { "text": "sound a little odd saying this is nice", "start": 8070.52, "duration": 4.159 }, { "text": "to read but indeed student doget just", "start": 8072.159, "duration": 4.201 }, { "text": "tells me what's going on I'm going to", "start": 8074.679, "duration": 3.56 }, { "text": "get a student I don't need a separate", "start": 8076.36, "duration": 3.44 }, { "text": "function written by me called get", "start": 8078.239, "duration": 4.0 }, { "text": "student in the file itself the get", "start": 8079.8, "duration": 4.96 }, { "text": "functionality is built into the class", "start": 8082.239, "duration": 4.32 }, { "text": "all my student related code now is", "start": 8084.76, "duration": 3.56 }, { "text": "together so let me go down to my", "start": 8086.559, "duration": 3.201 }, { "text": "terminal window and run python of", "start": 8088.32, "duration": 3.919 }, { "text": "student. enter let's type in Harry let's", "start": 8089.76, "duration": 4.28 }, { "text": "type in Gryffindor and we're back to", "start": 8092.239, "duration": 4.84 }, { "text": "where we began but but but everything", "start": 8094.04, "duration": 5.84 }, { "text": "related to students now is in this here", "start": 8097.079, "duration": 5.201 }, { "text": "class the only other thing in the file", "start": 8099.88, "duration": 4.759 }, { "text": "is Main and this conditional that we", "start": 8102.28, "duration": 4.24 }, { "text": "always use to avoid accidentally", "start": 8104.639, "duration": 3.761 }, { "text": "executing main when we're making a", "start": 8106.52, "duration": 4.8 }, { "text": "module or a package or the like so again", "start": 8108.4, "duration": 6.199 }, { "text": "a solution to a problem not a big one in", "start": 8111.32, "duration": 5.0 }, { "text": "the case of a relatively small program", "start": 8114.599, "duration": 3.281 }, { "text": "but one that you will eventually", "start": 8116.32, "duration": 3.2 }, { "text": "counters your programs get longer and", "start": 8117.88, "duration": 5.279 }, { "text": "longer with more and more entities to", "start": 8119.52, "duration": 7.76 }, { "text": "represent questions now on this use of a", "start": 8123.159, "duration": 6.681 }, { "text": "class method does the does the class", "start": 8127.28, "duration": 4.52 }, { "text": "have to be defined before the main", "start": 8129.84, "duration": 4.279 }, { "text": "function in terms of the order of the of", "start": 8131.8, "duration": 4.16 }, { "text": "the program a really good question so", "start": 8134.119, "duration": 3.281 }, { "text": "when in doubt let's try this so let's", "start": 8135.96, "duration": 3.08 }, { "text": "try to change the order let's move main", "start": 8137.4, "duration": 3.799 }, { "text": "to the top which I've often encouraged", "start": 8139.04, "duration": 4.559 }, { "text": "so let's go ahead and above the class do", "start": 8141.199, "duration": 4.721 }, { "text": "this and notice now that technically", "start": 8143.599, "duration": 5.0 }, { "text": "line two is mentioning student which", "start": 8145.92, "duration": 5.44 }, { "text": "does not exist until line six and Below", "start": 8148.599, "duration": 4.04 }, { "text": "let me go ahead and clear my terminal", "start": 8151.36, "duration": 4.04 }, { "text": "and run python of student. so far so", "start": 8152.639, "duration": 6.321 }, { "text": "good Harry Gryffindor okay uh and indeed", "start": 8155.4, "duration": 5.799 }, { "text": "Harry's from Gryffindor the reason", "start": 8158.96, "duration": 4.48 }, { "text": "Michael it does not matter in this case", "start": 8161.199, "duration": 4.04 }, { "text": "is because we're not actually calling", "start": 8163.44, "duration": 4.199 }, { "text": "Maine until the very end and just as in", "start": 8165.239, "duration": 4.041 }, { "text": "the past that means that python has a", "start": 8167.639, "duration": 3.121 }, { "text": "chance to read everything top to bottom", "start": 8169.28, "duration": 3.959 }, { "text": "left to right so everything exists I", "start": 8170.76, "duration": 5.2 }, { "text": "would say generally classes are defined", "start": 8173.239, "duration": 5.041 }, { "text": "at the top of the file however it would", "start": 8175.96, "duration": 4.8 }, { "text": "be even maybe cleaner to move the", "start": 8178.28, "duration": 4.879 }, { "text": "class's definition to its own file and", "start": 8180.76, "duration": 4.6 }, { "text": "then import it so essentially to make", "start": 8183.159, "duration": 4.281 }, { "text": "reusable code by putting it into your", "start": 8185.36, "duration": 3.879 }, { "text": "own module or package so that not just", "start": 8187.44, "duration": 3.96 }, { "text": "this program but many others can use", "start": 8189.239, "duration": 4.48 }, { "text": "that definition of student as well other", "start": 8191.4, "duration": 5.319 }, { "text": "questions now on classes class methods", "start": 8193.719, "duration": 5.201 }, { "text": "or the like I wanted to ask is there a", "start": 8196.719, "duration": 6.96 }, { "text": "way to um like declare all the all the", "start": 8198.92, "duration": 7.92 }, { "text": "possible all the possible attributes of", "start": 8203.679, "duration": 4.521 }, { "text": "the class because", "start": 8206.84, "duration": 5.12 }, { "text": "it looks so inconsistent um well so my", "start": 8208.2, "duration": 5.6 }, { "text": "takeaway there is this is Python's", "start": 8211.96, "duration": 3.399 }, { "text": "approach to these principles different", "start": 8213.8, "duration": 3.08 }, { "text": "languages like Java just take a", "start": 8215.359, "duration": 3.32 }, { "text": "different approach but have very similar", "start": 8216.88, "duration": 4.36 }, { "text": "features the syntax just tends to vary", "start": 8218.679, "duration": 4.441 }, { "text": "and this is how the python Community", "start": 8221.24, "duration": 4.399 }, { "text": "chose to implement this idea the right", "start": 8223.12, "duration": 4.359 }, { "text": "mental model ultimately is that these", "start": 8225.639, "duration": 4.601 }, { "text": "instance variables instant methods", "start": 8227.479, "duration": 7.281 }, { "text": "belong to or operate on specific objects", "start": 8230.24, "duration": 8.04 }, { "text": "a specific student a specific hat class", "start": 8234.76, "duration": 6.24 }, { "text": "variables and class methods operate on", "start": 8238.28, "duration": 6.359 }, { "text": "the entire class itself or in turn all", "start": 8241.0, "duration": 5.16 }, { "text": "objects of that class which we've not", "start": 8244.639, "duration": 3.641 }, { "text": "seen them a demonstration of but it's", "start": 8246.16, "duration": 4.08 }, { "text": "sort of a higher level concept so it", "start": 8248.28, "duration": 4.119 }, { "text": "turns out besides these class methods", "start": 8250.24, "duration": 4.079 }, { "text": "which are distinct from those instance", "start": 8252.399, "duration": 3.681 }, { "text": "methods which to be fair do not have", "start": 8254.319, "duration": 3.761 }, { "text": "their own decorator they just are by", "start": 8256.08, "duration": 3.68 }, { "text": "default instance method there's yet", "start": 8258.08, "duration": 3.16 }, { "text": "other types of methods you can have in", "start": 8259.76, "duration": 3.36 }, { "text": "classes in Python they tend to be called", "start": 8261.24, "duration": 3.92 }, { "text": "Static methods and they too come with", "start": 8263.12, "duration": 3.8 }, { "text": "another decorator called at static", "start": 8265.16, "duration": 3.479 }, { "text": "method which which is a rabbit hole we", "start": 8266.92, "duration": 3.92 }, { "text": "won't go down but realize that there is", "start": 8268.639, "duration": 3.92 }, { "text": "yet other functionality that you can", "start": 8270.84, "duration": 3.12 }, { "text": "leverage within object-oriented", "start": 8272.559, "duration": 3.401 }, { "text": "programming but what we thought we do is", "start": 8273.96, "duration": 4.88 }, { "text": "focus really on some final core features", "start": 8275.96, "duration": 4.519 }, { "text": "that you see not just in Python but", "start": 8278.84, "duration": 3.799 }, { "text": "other languages as well and perhaps one", "start": 8280.479, "duration": 3.801 }, { "text": "of the most compelling features of", "start": 8282.639, "duration": 3.241 }, { "text": "object-oriented programming that we", "start": 8284.28, "duration": 3.88 }, { "text": "haven't yet used explicitly though it", "start": 8285.88, "duration": 4.639 }, { "text": "turns out we've seen implicitly over the", "start": 8288.16, "duration": 5.399 }, { "text": "past weeks is this notion of inheritance", "start": 8290.519, "duration": 5.04 }, { "text": "it turns out via object-oriented", "start": 8293.559, "duration": 3.241 }, { "text": "programming there's actually an", "start": 8295.559, "duration": 4.561 }, { "text": "opportunity to design your classes in a", "start": 8296.8, "duration": 5.719 }, { "text": "hierarchical fashion whereby you can", "start": 8300.12, "duration": 6.439 }, { "text": "have one class inherit from or borrow", "start": 8302.519, "duration": 6.88 }, { "text": "attributes that is methods or variables", "start": 8306.559, "duration": 5.241 }, { "text": "from another class if they all have", "start": 8309.399, "duration": 5.0 }, { "text": "those in common so what do I mean by", "start": 8311.8, "duration": 5.16 }, { "text": "this here well let me propose that we", "start": 8314.399, "duration": 5.28 }, { "text": "Implement uh over in vs code here a", "start": 8316.96, "duration": 5.359 }, { "text": "brand new file called wizard. piy let me", "start": 8319.679, "duration": 6.161 }, { "text": "go ahead and run code of wizard. piy and", "start": 8322.319, "duration": 6.04 }, { "text": "then let's start as before for defining", "start": 8325.84, "duration": 5.04 }, { "text": "a class called student and let's go", "start": 8328.359, "duration": 4.441 }, { "text": "ahead and first Define the underscore", "start": 8330.88, "duration": 4.32 }, { "text": "uncore init method which of course is", "start": 8332.8, "duration": 3.799 }, { "text": "minimally going to take an argument", "start": 8335.2, "duration": 3.119 }, { "text": "traditionally called self and in this", "start": 8336.599, "duration": 3.441 }, { "text": "case let's also have it take as before a", "start": 8338.319, "duration": 4.441 }, { "text": "name and a house and then in this init", "start": 8340.04, "duration": 4.72 }, { "text": "method let's go ahead and assign the", "start": 8342.76, "duration": 4.759 }, { "text": "instance variables self. name equals", "start": 8344.76, "duration": 6.599 }, { "text": "name and self. house equals house let's", "start": 8347.519, "duration": 5.0 }, { "text": "assume that there's some other", "start": 8351.359, "duration": 3.08 }, { "text": "functionality in this class as well dot", "start": 8352.519, "duration": 3.721 }, { "text": "dot dot but let's move on now to", "start": 8354.439, "duration": 3.761 }, { "text": "implementing the notion of a a professor", "start": 8356.24, "duration": 4.56 }, { "text": "in The Wizarding World as well so for", "start": 8358.2, "duration": 5.519 }, { "text": "this class let's call it", "start": 8360.8, "duration": 5.559 }, { "text": "professor and a professor let's say is", "start": 8363.719, "duration": 4.121 }, { "text": "also going to have its own", "start": 8366.359, "duration": 3.32 }, { "text": "initialization method so underscore", "start": 8367.84, "duration": 3.839 }, { "text": "underscore in it it's going to take self", "start": 8369.679, "duration": 4.161 }, { "text": "as always as the first argument uh a", "start": 8371.679, "duration": 4.161 }, { "text": "professor also has a name so we'll pass", "start": 8373.84, "duration": 4.4 }, { "text": "that in second to and even though some", "start": 8375.84, "duration": 4.2 }, { "text": "professors are heads of houses let's", "start": 8378.24, "duration": 3.239 }, { "text": "assume that a professor is really", "start": 8380.04, "duration": 2.92 }, { "text": "identified by their name and their", "start": 8381.479, "duration": 3.84 }, { "text": "subject area the class that they teach", "start": 8382.96, "duration": 4.16 }, { "text": "so we'll call this third argument", "start": 8385.319, "duration": 3.881 }, { "text": "subject subject now as before let's go", "start": 8387.12, "duration": 4.8 }, { "text": "ahead and assign self. name equals name", "start": 8389.2, "duration": 5.96 }, { "text": "and let's assign self. sub equals", "start": 8391.92, "duration": 5.32 }, { "text": "subject here and as before let's assume", "start": 8395.16, "duration": 3.48 }, { "text": "that there's some more functionality", "start": 8397.24, "duration": 4.04 }, { "text": "associated with professors as well well", "start": 8398.64, "duration": 4.799 }, { "text": "what do you notice already here in my", "start": 8401.28, "duration": 5.039 }, { "text": "definitions of students and", "start": 8403.439, "duration": 5.081 }, { "text": "professors typically we're a bit", "start": 8406.319, "duration": 4.681 }, { "text": "reluctant to allow for any redundancy in", "start": 8408.52, "duration": 5.36 }, { "text": "our code and here I feel like my init", "start": 8411.0, "duration": 5.0 }, { "text": "method is taking a name for students my", "start": 8413.88, "duration": 4.12 }, { "text": "init method is also taking name for a", "start": 8416.0, "duration": 3.479 }, { "text": "professor and I have these identical", "start": 8418.0, "duration": 3.96 }, { "text": "lines of code like self. name equals", "start": 8419.479, "duration": 3.84 }, { "text": "name and this is only going to get", "start": 8421.96, "duration": 3.2 }, { "text": "exacerbated if I now go and add some", "start": 8423.319, "duration": 4.321 }, { "text": "error checking so for instance How about", "start": 8425.16, "duration": 5.48 }, { "text": "if uh if not name we should probably be", "start": 8427.64, "duration": 4.679 }, { "text": "in the habit of raising something like a", "start": 8430.64, "duration": 3.96 }, { "text": "value error and an explanatory message", "start": 8432.319, "duration": 5.12 }, { "text": "like missing name and you know what if a", "start": 8434.6, "duration": 4.6 }, { "text": "professor is missing their name I should", "start": 8437.439, "duration": 3.561 }, { "text": "probably copy paste that code down here", "start": 8439.2, "duration": 3.68 }, { "text": "and that's where Red Flag should be", "start": 8441.0, "duration": 3.6 }, { "text": "going off whereby as soon as you start", "start": 8442.88, "duration": 4.64 }, { "text": "copy pasting code there's probably a", "start": 8444.6, "duration": 4.68 }, { "text": "better way so that we can write the code", "start": 8447.52, "duration": 3.959 }, { "text": "once and perhaps reuse it in some way", "start": 8449.28, "duration": 4.36 }, { "text": "and here too object-oriented programming", "start": 8451.479, "duration": 4.721 }, { "text": "offers a solution it turns out that", "start": 8453.64, "duration": 4.24 }, { "text": "object-oriented programming in Python", "start": 8456.2, "duration": 4.68 }, { "text": "also supports inheritance whereby you", "start": 8457.88, "duration": 5.88 }, { "text": "can Define multiple classes that somehow", "start": 8460.88, "duration": 4.68 }, { "text": "relate to one another they don't need to", "start": 8463.76, "duration": 3.92 }, { "text": "exist sort of in parallel in this way", "start": 8465.56, "duration": 3.799 }, { "text": "there could actually be some hierarchy", "start": 8467.68, "duration": 3.4 }, { "text": "between them so for instance in The", "start": 8469.359, "duration": 3.561 }, { "text": "Wizarding World we could argue that both", "start": 8471.08, "duration": 3.92 }, { "text": "a student and a professor are at the end", "start": 8472.92, "duration": 4.64 }, { "text": "of the day Wizards so maybe what should", "start": 8475.0, "duration": 4.6 }, { "text": "really Define is a third class for", "start": 8477.56, "duration": 4.32 }, { "text": "instance called wizard that has any of", "start": 8479.6, "duration": 5.36 }, { "text": "the common attributes for students and", "start": 8481.88, "duration": 4.599 }, { "text": "professors alike and for now we've kept", "start": 8484.96, "duration": 3.16 }, { "text": "it relatively simple the only thing they", "start": 8486.479, "duration": 4.121 }, { "text": "have in common is a name and a name in", "start": 8488.12, "duration": 4.319 }, { "text": "student and Professor respectively so", "start": 8490.6, "duration": 4.12 }, { "text": "why don't we minimally factor that out", "start": 8492.439, "duration": 4.681 }, { "text": "first all right so let me go ahead here", "start": 8494.72, "duration": 3.88 }, { "text": "and just to keep things organized at the", "start": 8497.12, "duration": 3.239 }, { "text": "top of my file let's define a third", "start": 8498.6, "duration": 4.32 }, { "text": "class called Wizard and a wizard will", "start": 8500.359, "duration": 4.801 }, { "text": "have its own initialization method so", "start": 8502.92, "duration": 5.36 }, { "text": "decore uncore init underscore uncore and", "start": 8505.16, "duration": 5.52 }, { "text": "self as always and a wizard let's say", "start": 8508.28, "duration": 4.88 }, { "text": "for now is only going to be initialized", "start": 8510.68, "duration": 5.84 }, { "text": "with their name in this way and now I'm", "start": 8513.16, "duration": 4.64 }, { "text": "going to go ahead and do some of that", "start": 8516.52, "duration": 3.16 }, { "text": "error checking so if not name we'll", "start": 8517.8, "duration": 4.8 }, { "text": "raise a value error in the Wizard class", "start": 8519.68, "duration": 5.04 }, { "text": "otherwise we'll go ahead and do self.", "start": 8522.6, "duration": 4.719 }, { "text": "name equals name and heck dot dot dot", "start": 8524.72, "duration": 4.88 }, { "text": "maybe some other functionality as well", "start": 8527.319, "duration": 4.201 }, { "text": "but not a subject which is specific to", "start": 8529.6, "duration": 3.68 }, { "text": "professors and not a house which I've", "start": 8531.52, "duration": 4.28 }, { "text": "claimed is specific to students now I", "start": 8533.28, "duration": 5.0 }, { "text": "think we can begin to maybe remove some", "start": 8535.8, "duration": 4.599 }, { "text": "of the redundancies in our other classes", "start": 8538.28, "duration": 5.44 }, { "text": "here so for instance down with student", "start": 8540.399, "duration": 5.281 }, { "text": "why don't I go ahead and remove this", "start": 8543.72, "duration": 4.12 }, { "text": "error checking here and remove this", "start": 8545.68, "duration": 4.719 }, { "text": "error this assignment of self. name", "start": 8547.84, "duration": 4.44 }, { "text": "equals name because I'm already doing", "start": 8550.399, "duration": 3.881 }, { "text": "that in Wizard and similarly down here", "start": 8552.28, "duration": 3.52 }, { "text": "in Professor why don't I do the same", "start": 8554.28, "duration": 3.119 }, { "text": "let's get rid of the error checking", "start": 8555.8, "duration": 3.559 }, { "text": "let's get rid of self. name equals name", "start": 8557.399, "duration": 3.481 }, { "text": "because I'm again I'm doing that already", "start": 8559.359, "duration": 4.241 }, { "text": "up there for Wizard as well but at the", "start": 8560.88, "duration": 4.28 }, { "text": "moment even though they're all in the", "start": 8563.6, "duration": 3.96 }, { "text": "same file I haven't told python that a", "start": 8565.16, "duration": 4.8 }, { "text": "student is a wizard and a professor is a", "start": 8567.56, "duration": 4.36 }, { "text": "wizard so I really need to link these", "start": 8569.96, "duration": 3.92 }, { "text": "two together and the way you can", "start": 8571.92, "duration": 5.08 }, { "text": "prescribe inheritance whereby one class", "start": 8573.88, "duration": 4.92 }, { "text": "should inherit from another or", "start": 8577.0, "duration": 4.0 }, { "text": "conversely one class should descend for", "start": 8578.8, "duration": 4.76 }, { "text": "another from another we can do this I", "start": 8581.0, "duration": 4.72 }, { "text": "can say class student but before the", "start": 8583.56, "duration": 4.759 }, { "text": "colon I can go in and say in parenthesis", "start": 8585.72, "duration": 6.04 }, { "text": "a student inherits from or is a subclass", "start": 8588.319, "duration": 6.321 }, { "text": "of wizard which conversely is the super", "start": 8591.76, "duration": 5.8 }, { "text": "class of the student class so this means", "start": 8594.64, "duration": 4.96 }, { "text": "that when I Define a student class go", "start": 8597.56, "duration": 3.52 }, { "text": "ahead and inherit all of the", "start": 8599.6, "duration": 4.32 }, { "text": "characteristics of a wizard as well and", "start": 8601.08, "duration": 4.44 }, { "text": "I'm going to do the same thing for her", "start": 8603.92, "duration": 4.519 }, { "text": "for Professor so parenthesis wizard", "start": 8605.52, "duration": 4.6 }, { "text": "after the class name professor and", "start": 8608.439, "duration": 3.281 }, { "text": "that's going to give me access to some", "start": 8610.12, "duration": 2.88 }, { "text": "of that same", "start": 8611.72, "duration": 3.8 }, { "text": "functionality but because my student", "start": 8613.0, "duration": 4.68 }, { "text": "class and my professor class still have", "start": 8615.52, "duration": 4.44 }, { "text": "their same init methods those are the", "start": 8617.68, "duration": 3.44 }, { "text": "methods that are going to get called", "start": 8619.96, "duration": 3.2 }, { "text": "whenever I create a student in code or I", "start": 8621.12, "duration": 4.359 }, { "text": "create a professor in code I need to", "start": 8623.16, "duration": 4.4 }, { "text": "somehow explicitly say that I also want", "start": 8625.479, "duration": 4.481 }, { "text": "to use the functionality in the Wizard", "start": 8627.56, "duration": 5.08 }, { "text": "classes init method and the way to do", "start": 8629.96, "duration": 4.92 }, { "text": "this in Python is is as follows let me", "start": 8632.64, "duration": 4.48 }, { "text": "go into my init method for student and", "start": 8634.88, "duration": 4.76 }, { "text": "let me call Super with no arguments", "start": 8637.12, "duration": 5.04 }, { "text": "which is a reference to the super class", "start": 8639.64, "duration": 4.52 }, { "text": "of this class so if this class is", "start": 8642.16, "duration": 3.76 }, { "text": "student the super class that is the", "start": 8644.16, "duration": 4.8 }, { "text": "parent class is Wizard so super open", "start": 8645.92, "duration": 5.8 }, { "text": "paren Clos paren will have the effect of", "start": 8648.96, "duration": 5.68 }, { "text": "accessing the super class and then I'm", "start": 8651.72, "duration": 4.679 }, { "text": "going to go ahead and explicitly call", "start": 8654.64, "duration": 4.08 }, { "text": "its in it method and I'm going to pass", "start": 8656.399, "duration": 6.121 }, { "text": "to the Wizards init method the name that", "start": 8658.72, "duration": 6.48 }, { "text": "the students init method was passed and", "start": 8662.52, "duration": 4.24 }, { "text": "I'm going to go ahead and do the same", "start": 8665.2, "duration": 3.6 }, { "text": "down here in Wizard this is one line of", "start": 8666.76, "duration": 4.44 }, { "text": "copy paste but I think I'm okay with it", "start": 8668.8, "duration": 4.0 }, { "text": "here because it's still allowing me to", "start": 8671.2, "duration": 3.079 }, { "text": "do all of the name assignment and the", "start": 8672.8, "duration": 3.4 }, { "text": "error checking up in the Wizard class", "start": 8674.279, "duration": 4.761 }, { "text": "instead I think we're okay now by just", "start": 8676.2, "duration": 6.159 }, { "text": "calling super. init for both student and", "start": 8679.04, "duration": 5.6 }, { "text": "Professor alike now admittedly this", "start": 8682.359, "duration": 4.721 }, { "text": "syntax is definitely out there the fact", "start": 8684.64, "duration": 4.16 }, { "text": "that we're calling super and parentheses", "start": 8687.08, "duration": 3.56 }, { "text": "and dots and underscore underscore on", "start": 8688.8, "duration": 3.96 }, { "text": "the left and the right of init here but", "start": 8690.64, "duration": 3.56 }, { "text": "it's just a combination of these two", "start": 8692.76, "duration": 3.76 }, { "text": "ideas super open parenthesis closed", "start": 8694.2, "duration": 4.36 }, { "text": "parenthesis is a way of programmatically", "start": 8696.52, "duration": 4.56 }, { "text": "accessing a current class's parent class", "start": 8698.56, "duration": 4.799 }, { "text": "or super class and underscore uncore in", "start": 8701.08, "duration": 4.12 }, { "text": "it of course is just referring to now", "start": 8703.359, "duration": 4.881 }, { "text": "that class's own initialization method", "start": 8705.2, "duration": 4.56 }, { "text": "now per the dot dot dots there could be", "start": 8708.24, "duration": 3.28 }, { "text": "a lot more going on in these classes but", "start": 8709.76, "duration": 4.84 }, { "text": "what's nice now is that wizard as a", "start": 8711.52, "duration": 4.919 }, { "text": "class is taking care of all of the", "start": 8714.6, "duration": 3.759 }, { "text": "assignments of a Wizard's name whether", "start": 8716.439, "duration": 3.92 }, { "text": "that wizard is a student or a professor", "start": 8718.359, "duration": 3.521 }, { "text": "and it's even doing some error checking", "start": 8720.359, "duration": 3.441 }, { "text": "to make sure that the name was actually", "start": 8721.88, "duration": 5.08 }, { "text": "passed in meanwhile student is", "start": 8723.8, "duration": 5.44 }, { "text": "inheriting all of that functionality and", "start": 8726.96, "duration": 4.28 }, { "text": "using it by calling the super class's", "start": 8729.24, "duration": 4.0 }, { "text": "own init method but it's additionally", "start": 8731.24, "duration": 3.64 }, { "text": "taking the house that's presumably", "start": 8733.24, "duration": 3.44 }, { "text": "passed into the student Constructor", "start": 8734.88, "duration": 4.0 }, { "text": "function and assigning it to its own", "start": 8736.68, "duration": 4.28 }, { "text": "instance variable self. house and", "start": 8738.88, "duration": 4.16 }, { "text": "similarly Professor are restoring in", "start": 8740.96, "duration": 4.24 }, { "text": "self-thought subject the subject that", "start": 8743.04, "duration": 4.76 }, { "text": "was passed into there that one as well", "start": 8745.2, "duration": 4.88 }, { "text": "now how might we use these classes well", "start": 8747.8, "duration": 4.36 }, { "text": "we'll continue to wave our hands with a", "start": 8750.08, "duration": 3.76 }, { "text": "little bit of detail here but if at the", "start": 8752.16, "duration": 3.279 }, { "text": "bottom of this file or any other file", "start": 8753.84, "duration": 3.96 }, { "text": "that Imports this one I could now write", "start": 8755.439, "duration": 4.281 }, { "text": "code like this I could create a student", "start": 8757.8, "duration": 4.08 }, { "text": "variable and assign it the return value", "start": 8759.72, "duration": 3.679 }, { "text": "of the student Constructor call and", "start": 8761.88, "duration": 4.08 }, { "text": "maybe that student is named Harry and", "start": 8763.399, "duration": 4.96 }, { "text": "that student's house for instance might", "start": 8765.96, "duration": 5.399 }, { "text": "be Gryffindor and meanwhile I might do", "start": 8768.359, "duration": 5.241 }, { "text": "something like this professor equals", "start": 8771.359, "duration": 3.801 }, { "text": "professor over here and notice the", "start": 8773.6, "duration": 4.48 }, { "text": "lowercase s on the left capital S on the", "start": 8775.16, "duration": 4.72 }, { "text": "right same for Professor on the left", "start": 8778.08, "duration": 3.72 }, { "text": "lowercase and uppercase on the right", "start": 8779.88, "duration": 4.16 }, { "text": "respectively Professor quote unquote", "start": 8781.8, "duration": 6.36 }, { "text": "seus and how about defense against the", "start": 8784.04, "duration": 6.68 }, { "text": "dark arts will be his subject and", "start": 8788.16, "duration": 4.48 }, { "text": "meanwhile if we want more generically", "start": 8790.72, "duration": 4.48 }, { "text": "just a wizard who at the moment is", "start": 8792.64, "duration": 4.799 }, { "text": "neither student nor Professor teaching", "start": 8795.2, "duration": 4.119 }, { "text": "classes actively we could even do that", "start": 8797.439, "duration": 4.721 }, { "text": "we could do wizard equals wizard in", "start": 8799.319, "duration": 4.521 }, { "text": "capital W on the right hand side of the", "start": 8802.16, "duration": 2.96 }, { "text": "equal sign because it's the name of the", "start": 8803.84, "duration": 3.84 }, { "text": "class and someone like Alin passing in", "start": 8805.12, "duration": 6.68 }, { "text": "only albus's name not a house not a", "start": 8807.68, "duration": 6.48 }, { "text": "subject because in this case he's known", "start": 8811.8, "duration": 5.0 }, { "text": "only as a wizard meanwhile with each of", "start": 8814.16, "duration": 4.88 }, { "text": "these calls this line of code here will", "start": 8816.8, "duration": 3.679 }, { "text": "ensure that the init method for the", "start": 8819.04, "duration": 3.64 }, { "text": "wizard class is called this line of code", "start": 8820.479, "duration": 4.441 }, { "text": "here will ensure that the init method of", "start": 8822.68, "duration": 4.2 }, { "text": "the student class and in turn the init", "start": 8824.92, "duration": 3.68 }, { "text": "method of the super class wizard is", "start": 8826.88, "duration": 3.72 }, { "text": "called and then lastly on this final", "start": 8828.6, "duration": 4.839 }, { "text": "line of code will this syntax ensure", "start": 8830.6, "duration": 4.6 }, { "text": "that the init method of the professor", "start": 8833.439, "duration": 3.721 }, { "text": "class is called which in turn calls the", "start": 8835.2, "duration": 5.04 }, { "text": "init method of the super class as well", "start": 8837.16, "duration": 5.72 }, { "text": "any questions now on this idea of", "start": 8840.24, "duration": 5.36 }, { "text": "inheritance which is a key feature of a", "start": 8842.88, "duration": 3.8 }, { "text": "lot of", "start": 8845.6, "duration": 3.759 }, { "text": "objectoriented programming languages um", "start": 8846.68, "duration": 6.44 }, { "text": "so is there any situation where because", "start": 8849.359, "duration": 5.401 }, { "text": "uh from what I've seen so far A lot of", "start": 8853.12, "duration": 3.52 }, { "text": "times there's like a lot of nesting if", "start": 8854.76, "duration": 3.519 }, { "text": "you do superar does it go one up is", "start": 8856.64, "duration": 3.36 }, { "text": "there any situation where you know it's", "start": 8858.279, "duration": 5.521 }, { "text": "nested in another class as well um above", "start": 8860.0, "duration": 5.72 }, { "text": "wizard let's say a really good question", "start": 8863.8, "duration": 4.04 }, { "text": "if you were to have a a super super", "start": 8865.72, "duration": 4.04 }, { "text": "class so your hierarchy is even taller", "start": 8867.84, "duration": 4.96 }, { "text": "than the two levels of uh hierarchy that", "start": 8869.76, "duration": 5.16 }, { "text": "we currently have absolutely but what's", "start": 8872.8, "duration": 4.04 }, { "text": "nice about object-oriented Pro what's", "start": 8874.92, "duration": 3.519 }, { "text": "nice about inheritance as the name", "start": 8876.84, "duration": 3.479 }, { "text": "implies is just as you might have", "start": 8878.439, "duration": 4.241 }, { "text": "inherited certain traits as a human from", "start": 8880.319, "duration": 4.641 }, { "text": "your grandfather and grandmother or your", "start": 8882.68, "duration": 4.28 }, { "text": "great-grandfather or great-grandmother", "start": 8884.96, "duration": 4.439 }, { "text": "some of those properties can actually uh", "start": 8886.96, "duration": 4.24 }, { "text": "trickle down to you so to speak in the", "start": 8889.399, "duration": 5.201 }, { "text": "context of code as well so when you", "start": 8891.2, "duration": 6.44 }, { "text": "descend from another class that is when", "start": 8894.6, "duration": 6.04 }, { "text": "you subass a a super class or a super", "start": 8897.64, "duration": 5.16 }, { "text": "super class you actually do inherit all", "start": 8900.64, "duration": 3.759 }, { "text": "of the functionality not just from one", "start": 8902.8, "duration": 3.96 }, { "text": "level above you but from two or three so", "start": 8904.399, "duration": 4.0 }, { "text": "you can indeed access some of that", "start": 8906.76, "duration": 3.24 }, { "text": "functionality as well and you can even", "start": 8908.399, "duration": 3.641 }, { "text": "override it if you want some of these", "start": 8910.0, "duration": 3.399 }, { "text": "classes to behave a little bit", "start": 8912.04, "duration": 4.48 }, { "text": "differently than others other questions", "start": 8913.399, "duration": 5.561 }, { "text": "on inheritance so it's kind of similar", "start": 8916.52, "duration": 4.12 }, { "text": "to the last one but can you have like", "start": 8918.96, "duration": 4.84 }, { "text": "two parents on the same level a really", "start": 8920.64, "duration": 5.16 }, { "text": "good question so there are ways to", "start": 8923.8, "duration": 5.12 }, { "text": "implement uh um descendants from", "start": 8925.8, "duration": 4.519 }, { "text": "multiple parents and there's different", "start": 8928.92, "duration": 3.12 }, { "text": "ways to do this not just in Python but", "start": 8930.319, "duration": 3.841 }, { "text": "other languages we've kept things simple", "start": 8932.04, "duration": 4.16 }, { "text": "here though by having a single uh", "start": 8934.16, "duration": 4.48 }, { "text": "inheritance path a good question how", "start": 8936.2, "duration": 4.8 }, { "text": "about one more question on inheritance", "start": 8938.64, "duration": 5.56 }, { "text": "can we have multiple arguments in", "start": 8941.0, "duration": 7.359 }, { "text": "super. double init yes but in this case", "start": 8944.2, "duration": 6.8 }, { "text": "I'm only passing a name on line 18 and", "start": 8948.359, "duration": 5.761 }, { "text": "I'm only passing in name on line 10 why", "start": 8951.0, "duration": 5.319 }, { "text": "because on line two when I Define the in", "start": 8954.12, "duration": 4.64 }, { "text": "it method for the wizard class I only", "start": 8956.319, "duration": 4.96 }, { "text": "expect a single argument but I could", "start": 8958.76, "duration": 3.92 }, { "text": "absolutely have under common", "start": 8961.279, "duration": 2.681 }, { "text": "functionality like I could add in a", "start": 8962.68, "duration": 3.36 }, { "text": "petronis if both students and professors", "start": 8963.96, "duration": 3.72 }, { "text": "have patronises that can come out of", "start": 8966.04, "duration": 4.16 }, { "text": "their wands I could have two arguments", "start": 8967.68, "duration": 4.719 }, { "text": "instead we've been using this feature of", "start": 8970.2, "duration": 3.84 }, { "text": "object-oriented programming now for", "start": 8972.399, "duration": 3.561 }, { "text": "quite some time in the form of", "start": 8974.04, "duration": 3.8 }, { "text": "exceptions indeed if you look at the", "start": 8975.96, "duration": 3.92 }, { "text": "official documentation for exceptions in", "start": 8977.84, "duration": 3.96 }, { "text": "Python you'll see that there's not even", "start": 8979.88, "duration": 3.68 }, { "text": "the ones we've seen in class like value", "start": 8981.8, "duration": 3.8 }, { "text": "error and others there's any number of", "start": 8983.56, "duration": 4.48 }, { "text": "others as well but they are all", "start": 8985.6, "duration": 4.4 }, { "text": "themselves hierarchical in nature this", "start": 8988.04, "duration": 4.279 }, { "text": "is just a subset of the available", "start": 8990.0, "duration": 4.2 }, { "text": "exceptions that come built into Python", "start": 8992.319, "duration": 3.681 }, { "text": "and you can actually as a programmer", "start": 8994.2, "duration": 4.0 }, { "text": "create your own exceptions as well but", "start": 8996.0, "duration": 4.92 }, { "text": "as this chart here uh captures", "start": 8998.2, "duration": 5.199 }, { "text": "hierarchically all exceptions we've seen", "start": 9000.92, "duration": 5.24 }, { "text": "thus far actually descend from or", "start": 9003.399, "duration": 5.721 }, { "text": "inherit from Super classes already so", "start": 9006.16, "duration": 4.48 }, { "text": "for instance at the bottom of this list", "start": 9009.12, "duration": 3.199 }, { "text": "here is value error which we've seen", "start": 9010.64, "duration": 3.92 }, { "text": "quite a bit and if you follow the line", "start": 9012.319, "duration": 4.441 }, { "text": "straight up on this asky rendition of", "start": 9014.56, "duration": 4.6 }, { "text": "this chart you'll see that value error", "start": 9016.76, "duration": 4.559 }, { "text": "has a parent class or super class called", "start": 9019.16, "duration": 4.0 }, { "text": "exception and the exception class", "start": 9021.319, "duration": 3.881 }, { "text": "meanwhile has a parent class called base", "start": 9023.16, "duration": 4.199 }, { "text": "exception why did the authors of python", "start": 9025.2, "duration": 4.04 }, { "text": "do this well it turns out that whether", "start": 9027.359, "duration": 5.441 }, { "text": "you have a uh value error or a key error", "start": 9029.24, "duration": 5.48 }, { "text": "or an assertion error or any number of", "start": 9032.8, "duration": 4.4 }, { "text": "others there's a lot of functionality", "start": 9034.72, "duration": 5.48 }, { "text": "common to all of those types of errors", "start": 9037.2, "duration": 5.84 }, { "text": "that you want uh all that you want a", "start": 9040.2, "duration": 5.36 }, { "text": "programmer to be able to use and so it", "start": 9043.04, "duration": 4.2 }, { "text": "turns out that the the authors of python", "start": 9045.56, "duration": 3.799 }, { "text": "decided you know what let's not have a", "start": 9047.24, "duration": 5.159 }, { "text": "dozen or more different classes that all", "start": 9049.359, "duration": 4.761 }, { "text": "just have copy pasted similar", "start": 9052.399, "duration": 3.441 }, { "text": "functionality let's create this", "start": 9054.12, "duration": 3.56 }, { "text": "hierarchy so that even though the", "start": 9055.84, "duration": 3.28 }, { "text": "exceptions toward the bottom of this", "start": 9057.68, "duration": 3.719 }, { "text": "list are very precise they at least", "start": 9059.12, "duration": 4.84 }, { "text": "inherit that is borrow some very common", "start": 9061.399, "duration": 4.761 }, { "text": "functionality up above so it turns out", "start": 9063.96, "duration": 4.2 }, { "text": "that when you use the try and the accept", "start": 9066.16, "duration": 4.36 }, { "text": "keyword in Python generally speaking", "start": 9068.16, "duration": 4.4 }, { "text": "we've tried to catch very specific", "start": 9070.52, "duration": 4.04 }, { "text": "exceptions like value error but", "start": 9072.56, "duration": 4.36 }, { "text": "technically you could capture the parent", "start": 9074.56, "duration": 4.44 }, { "text": "or even the grandparent exception", "start": 9076.92, "duration": 4.16 }, { "text": "forgiven exception especially if you're", "start": 9079.0, "duration": 3.72 }, { "text": "not necessarily sure which one is going", "start": 9081.08, "duration": 3.96 }, { "text": "to get raised or better yet there could", "start": 9082.72, "duration": 4.28 }, { "text": "be many exceptions that get raised but", "start": 9085.04, "duration": 3.92 }, { "text": "you want to handle them all the same and", "start": 9087.0, "duration": 3.6 }, { "text": "you don't want to necessarily enumerate", "start": 9088.96, "duration": 3.88 }, { "text": "them in parentheses separated by commas", "start": 9090.6, "duration": 3.759 }, { "text": "you want to say you want to handle all", "start": 9092.84, "duration": 4.04 }, { "text": "exceptions of a certain super class in", "start": 9094.359, "duration": 4.681 }, { "text": "much the same way so this has been", "start": 9096.88, "duration": 3.84 }, { "text": "latent this whole time anytime we've", "start": 9099.04, "duration": 4.04 }, { "text": "seen or used or caught or now raised", "start": 9100.72, "duration": 4.599 }, { "text": "exceptions and built into python is this", "start": 9103.08, "duration": 3.68 }, { "text": "hierarchy and if you were to invent your", "start": 9105.319, "duration": 3.521 }, { "text": "own exception generally you wouldn't", "start": 9106.76, "duration": 3.48 }, { "text": "want to start from scratch you would", "start": 9108.84, "duration": 4.08 }, { "text": "want to descend from that is subass one", "start": 9110.24, "duration": 4.6 }, { "text": "of these existing exceptions and add", "start": 9112.92, "duration": 3.88 }, { "text": "your own twist on it your own", "start": 9114.84, "duration": 4.92 }, { "text": "functionality as well well there's one", "start": 9116.8, "duration": 4.639 }, { "text": "final feature of object-oriented", "start": 9119.76, "duration": 3.44 }, { "text": "programming that we'd like to share with", "start": 9121.439, "duration": 4.081 }, { "text": "you today and that it will perhaps be", "start": 9123.2, "duration": 3.96 }, { "text": "quite the eyeopener is what you can", "start": 9125.52, "duration": 3.6 }, { "text": "really do now that you have classes at", "start": 9127.16, "duration": 4.8 }, { "text": "your disposal and this too surprise has", "start": 9129.12, "duration": 4.08 }, { "text": "been a feature you and I have been", "start": 9131.96, "duration": 3.56 }, { "text": "taking for granted for weeks now this", "start": 9133.2, "duration": 3.92 }, { "text": "has just worked but it's been", "start": 9135.52, "duration": 3.28 }, { "text": "implemented in a way that you can now", "start": 9137.12, "duration": 4.04 }, { "text": "leverage yourself it turns out that", "start": 9138.8, "duration": 4.36 }, { "text": "Python and some other languages too", "start": 9141.16, "duration": 4.199 }, { "text": "support this notion of operator", "start": 9143.16, "duration": 4.6 }, { "text": "overloading whereby you can take very", "start": 9145.359, "duration": 5.561 }, { "text": "common symbols like plus or minus or", "start": 9147.76, "duration": 6.08 }, { "text": "other such syntax on the on the keyboard", "start": 9150.92, "duration": 4.88 }, { "text": "and you can Implement your own", "start": 9153.84, "duration": 4.479 }, { "text": "interpretation thereof plus does not", "start": 9155.8, "duration": 5.72 }, { "text": "have to equal uh addition and minus does", "start": 9158.319, "duration": 5.0 }, { "text": "not have to equal subtraction and in", "start": 9161.52, "duration": 3.48 }, { "text": "fact you and I have already seen another", "start": 9163.319, "duration": 3.881 }, { "text": "context in which Plus plus means", "start": 9165.0, "duration": 5.359 }, { "text": "something else plus has not always in", "start": 9167.2, "duration": 6.76 }, { "text": "Python meant addition per se what else", "start": 9170.359, "duration": 6.801 }, { "text": "has python used Plus for concatenation", "start": 9173.96, "duration": 5.2 }, { "text": "for concatenation for joining two", "start": 9177.16, "duration": 4.64 }, { "text": "strings for adding to a list can you use", "start": 9179.16, "duration": 5.199 }, { "text": "plus as well so plus has actually been", "start": 9181.8, "duration": 5.0 }, { "text": "funny enough overloaded by the authors", "start": 9184.359, "duration": 5.0 }, { "text": "of python for us and so we can use the", "start": 9186.8, "duration": 4.559 }, { "text": "same symbol in much the same way as", "start": 9189.359, "duration": 3.561 }, { "text": "addition but with different data types", "start": 9191.359, "duration": 3.841 }, { "text": "to solve slightly different problems", "start": 9192.92, "duration": 3.96 }, { "text": "well let me propose that we go back over", "start": 9195.2, "duration": 3.84 }, { "text": "to vs code here and let me go ahead and", "start": 9196.88, "duration": 5.2 }, { "text": "create a new Final file called vault. py", "start": 9199.04, "duration": 5.84 }, { "text": "so code of vault. and let me propose", "start": 9202.08, "duration": 5.279 }, { "text": "that we implement the idea of a vault at", "start": 9204.88, "duration": 5.12 }, { "text": "Gringotts keeping on theme wherein", "start": 9207.359, "duration": 4.321 }, { "text": "there's a bank in the World of Harry", "start": 9210.0, "duration": 4.08 }, { "text": "Potter and within this Bank uh families", "start": 9211.68, "duration": 4.639 }, { "text": "and individuals have vaults containing", "start": 9214.08, "duration": 4.199 }, { "text": "all sorts of money in The Wizarding", "start": 9216.319, "duration": 3.761 }, { "text": "World and the type of money that exists", "start": 9218.279, "duration": 3.681 }, { "text": "in the World of Harry Potter are coins", "start": 9220.08, "duration": 4.52 }, { "text": "called gallions and sickles and canuts", "start": 9221.96, "duration": 4.439 }, { "text": "and those are in descending order of", "start": 9224.6, "duration": 3.759 }, { "text": "value and so inside of a vault might be", "start": 9226.399, "duration": 3.88 }, { "text": "a whole bunch of coins gold silver and", "start": 9228.359, "duration": 3.641 }, { "text": "bronze essentially each in those", "start": 9230.279, "duration": 4.321 }, { "text": "denominations tucked away so how can I", "start": 9232.0, "duration": 4.76 }, { "text": "go about implementing first of all the", "start": 9234.6, "duration": 4.56 }, { "text": "idea of a vault so that I can store for", "start": 9236.76, "duration": 4.84 }, { "text": "instance for Harry Potter how much uh", "start": 9239.16, "duration": 4.76 }, { "text": "coinage is in his family's Vault or for", "start": 9241.6, "duration": 4.6 }, { "text": "Juan resley the same well let me go", "start": 9243.92, "duration": 4.439 }, { "text": "ahead and Vault up high and first create", "start": 9246.2, "duration": 4.279 }, { "text": "a class called Vault essentially meant", "start": 9248.359, "duration": 4.361 }, { "text": "to represent a bank vault perfect", "start": 9250.479, "duration": 4.321 }, { "text": "another real world or fantasy world", "start": 9252.72, "duration": 4.12 }, { "text": "entity that I want to represent with", "start": 9254.8, "duration": 4.559 }, { "text": "code I could use a tupple or a list or a", "start": 9256.84, "duration": 3.92 }, { "text": "dictionary but again I'm going to get a", "start": 9259.359, "duration": 3.721 }, { "text": "lot more functionality with classes and", "start": 9260.76, "duration": 4.48 }, { "text": "we'll see one final flourish with", "start": 9263.08, "duration": 4.56 }, { "text": "operators inside of this Vault class", "start": 9265.24, "duration": 4.039 }, { "text": "let's go ahead and do this let me Define", "start": 9267.64, "duration": 4.2 }, { "text": "my init method taking its first argument", "start": 9269.279, "duration": 5.16 }, { "text": "of self and let me Define uh three", "start": 9271.84, "duration": 4.639 }, { "text": "arguments to this when you create a", "start": 9274.439, "duration": 4.681 }, { "text": "vault in my code here I want to be able", "start": 9276.479, "duration": 4.201 }, { "text": "to initialize it with some number of", "start": 9279.12, "duration": 3.319 }, { "text": "gallions some number of sickles and some", "start": 9280.68, "duration": 3.44 }, { "text": "number of canuts I want the US the", "start": 9282.439, "duration": 3.92 }, { "text": "programmer to be able to pass in one or", "start": 9284.12, "duration": 3.84 }, { "text": "more of those values ideally but they", "start": 9286.359, "duration": 2.881 }, { "text": "can be optional so I'll give them", "start": 9287.96, "duration": 3.56 }, { "text": "defaults so let's go ahead and Define a", "start": 9289.24, "duration": 4.239 }, { "text": "parameter called gallion whose default", "start": 9291.52, "duration": 4.2 }, { "text": "value will be zero sickles whose default", "start": 9293.479, "duration": 4.201 }, { "text": "value will also be zero and canuts whose", "start": 9295.72, "duration": 4.52 }, { "text": "default value will be zero as well so", "start": 9297.68, "duration": 5.16 }, { "text": "the programmer can pass in one or two or", "start": 9300.24, "duration": 4.239 }, { "text": "three or heck even none of those and", "start": 9302.84, "duration": 4.24 }, { "text": "they'll all have some implied defaults", "start": 9304.479, "duration": 4.96 }, { "text": "how do I want to remember those values", "start": 9307.08, "duration": 4.44 }, { "text": "that are passed in well let me do this", "start": 9309.439, "duration": 5.96 }, { "text": "self. gallion equals gallion and self.", "start": 9311.52, "duration": 7.4 }, { "text": "sickles equals sickles and self. canuts", "start": 9315.399, "duration": 6.92 }, { "text": "equals canuts and so I could add some", "start": 9318.92, "duration": 5.08 }, { "text": "error checking especially if you don't", "start": 9322.319, "duration": 3.521 }, { "text": "pass in a number I could turn these into", "start": 9324.0, "duration": 3.6 }, { "text": "properties to do even more validation", "start": 9325.84, "duration": 3.24 }, { "text": "but let's keep it simple and as always", "start": 9327.6, "duration": 3.56 }, { "text": "Focus only on the new ideas so I'm just", "start": 9329.08, "duration": 3.6 }, { "text": "going to trust that these values were", "start": 9331.16, "duration": 2.72 }, { "text": "passed in and I'm going to immediately", "start": 9332.68, "duration": 4.04 }, { "text": "assign them to these instance variables", "start": 9333.88, "duration": 4.96 }, { "text": "what now do I want to do well let's come", "start": 9336.72, "duration": 5.32 }, { "text": "up with a way of printing out what is in", "start": 9338.84, "duration": 5.519 }, { "text": "someone's Vault ultimately but first", "start": 9342.04, "duration": 4.6 }, { "text": "let's do this let's create a a vault for", "start": 9344.359, "duration": 5.0 }, { "text": "The Potters by creating via assignment a", "start": 9346.64, "duration": 4.639 }, { "text": "new Vault and let's say that the Potters", "start": 9349.359, "duration": 4.841 }, { "text": "have 100 gallions 50 sickles and 24", "start": 9351.279, "duration": 4.761 }, { "text": "canuts all right and that's in that", "start": 9354.2, "duration": 3.48 }, { "text": "Vault and let's print out for instance", "start": 9356.04, "duration": 3.64 }, { "text": "Potter all right let's run this code and", "start": 9357.68, "duration": 3.759 }, { "text": "see how it works now let me go ahead and", "start": 9359.68, "duration": 5.88 }, { "text": "run python a vault. enter okay seems to", "start": 9361.439, "duration": 6.601 }, { "text": "work no syntax errors or anything else", "start": 9365.56, "duration": 5.56 }, { "text": "but this is not very enlightening how do", "start": 9368.04, "duration": 6.04 }, { "text": "I fix this thinking back to what we've", "start": 9371.12, "duration": 5.44 }, { "text": "done before you have to use underscore", "start": 9374.08, "duration": 5.72 }, { "text": "uncore s exactly I need to use one of", "start": 9376.56, "duration": 4.96 }, { "text": "those special methods that comes with", "start": 9379.8, "duration": 4.519 }, { "text": "classes and Define for myself how I want", "start": 9381.52, "duration": 5.08 }, { "text": "a vault to be printed as a string so let", "start": 9384.319, "duration": 4.16 }, { "text": "me go ahead and do that let me Define", "start": 9386.6, "duration": 4.52 }, { "text": "the stir method taking in self as its", "start": 9388.479, "duration": 4.761 }, { "text": "sole argument here and let's just return", "start": 9391.12, "duration": 4.76 }, { "text": "a very simple string that just reveals", "start": 9393.24, "duration": 4.0 }, { "text": "what's in the vault so I'm going to", "start": 9395.88, "duration": 4.599 }, { "text": "return a formatted F string uh inside of", "start": 9397.24, "duration": 6.079 }, { "text": "which is self. gallion and then the word", "start": 9400.479, "duration": 5.281 }, { "text": "uh gallion so I know which those are uh", "start": 9403.319, "duration": 4.361 }, { "text": "then then let's do self. sickles and", "start": 9405.76, "duration": 4.04 }, { "text": "let's output the word sickles and then", "start": 9407.68, "duration": 4.12 }, { "text": "lastly let's output self. canuts and", "start": 9409.8, "duration": 4.559 }, { "text": "then canuts here so I know in this", "start": 9411.8, "duration": 5.479 }, { "text": "string just how many of each of those uh", "start": 9414.359, "duration": 5.481 }, { "text": "coins I have in this particular family's", "start": 9417.279, "duration": 4.961 }, { "text": "Vault all right let me go ahead and run", "start": 9419.84, "duration": 4.599 }, { "text": "python of vault. py changing nothing", "start": 9422.24, "duration": 4.6 }, { "text": "else except the stir method and now we", "start": 9424.439, "duration": 4.88 }, { "text": "see indeed that Harry has 100 gallions", "start": 9426.84, "duration": 5.32 }, { "text": "50 sickles and 25 canuts all right well", "start": 9429.319, "duration": 4.641 }, { "text": "let's do one thing more here below that", "start": 9432.16, "duration": 3.72 }, { "text": "let's go ahead and Define a Weasley", "start": 9433.96, "duration": 4.0 }, { "text": "variable and Ron never seemed to have", "start": 9435.88, "duration": 4.0 }, { "text": "quite as much uh money in the vault as", "start": 9437.96, "duration": 3.92 }, { "text": "did Harry so let's say that the Weasley", "start": 9439.88, "duration": 4.559 }, { "text": "Vault will have 25 50 and a 100 so I'll", "start": 9441.88, "duration": 3.96 }, { "text": "just reverse the order of those", "start": 9444.439, "duration": 3.96 }, { "text": "denominations uh rather than Harry's 100", "start": 9445.84, "duration": 4.76 }, { "text": "5025 and now let me go ahead and print", "start": 9448.399, "duration": 5.92 }, { "text": "Weasley like this and let's go ahead and", "start": 9450.6, "duration": 5.679 }, { "text": "clear my terminal window run python of", "start": 9454.319, "duration": 4.321 }, { "text": "vaulty this time that stir method will", "start": 9456.279, "duration": 4.881 }, { "text": "be invoked twice once for each of those", "start": 9458.64, "duration": 4.88 }, { "text": "Vault objects and we'll see indeed that", "start": 9461.16, "duration": 4.96 }, { "text": "the first one for Harry's got 150 and2", "start": 9463.52, "duration": 6.08 }, { "text": "respectively versus runs 25 50 and 100", "start": 9466.12, "duration": 5.56 }, { "text": "respectively but now let's do something", "start": 9469.6, "duration": 4.32 }, { "text": "interesting suppose that you wanted to", "start": 9471.68, "duration": 4.719 }, { "text": "combine the contents of two vaults be it", "start": 9473.92, "duration": 4.16 }, { "text": "Harry's and Ron's or any other two", "start": 9476.399, "duration": 4.481 }, { "text": "people how would you go about doing this", "start": 9478.08, "duration": 5.56 }, { "text": "in code well if I wanted to combine the", "start": 9480.88, "duration": 5.04 }, { "text": "vaults for someone I could do this well", "start": 9483.64, "duration": 5.04 }, { "text": "I could do gallion equals let's do", "start": 9485.92, "duration": 7.08 }, { "text": "Potter do gallion uh plus Weasley do", "start": 9488.68, "duration": 6.48 }, { "text": "gallion that gives me a variable called", "start": 9493.0, "duration": 4.479 }, { "text": "gallions that has the sum of Harry and", "start": 9495.16, "duration": 5.4 }, { "text": "Ron's gallions let's next do sickles", "start": 9497.479, "duration": 6.92 }, { "text": "equals potter. sickles plus Weasley", "start": 9500.56, "duration": 6.799 }, { "text": "Doles and then lastly let's do canuts", "start": 9504.399, "duration": 6.88 }, { "text": "equals potter. canuts plus Weasley do", "start": 9507.359, "duration": 5.681 }, { "text": "canuts I've got three variables what can", "start": 9511.279, "duration": 3.441 }, { "text": "I now do with these values well let's", "start": 9513.04, "duration": 4.56 }, { "text": "create a third a new Vault uh total will", "start": 9514.72, "duration": 4.8 }, { "text": "be the name of this variable equals a", "start": 9517.6, "duration": 4.679 }, { "text": "new Vault capital V notice and now let's", "start": 9519.52, "duration": 4.24 }, { "text": "pass in those three new variables", "start": 9522.279, "duration": 5.281 }, { "text": "gallions sickles and Kuts and that's it", "start": 9523.76, "duration": 5.96 }, { "text": "and let's print out this total Vault so", "start": 9527.56, "duration": 4.04 }, { "text": "we should now see three vaults one for", "start": 9529.72, "duration": 4.24 }, { "text": "Harry for Ron and the combination the", "start": 9531.6, "duration": 4.08 }, { "text": "addition of the two let me go ahead and", "start": 9533.96, "duration": 4.08 }, { "text": "rerun python of vaulty and there we have", "start": 9535.68, "duration": 7.36 }, { "text": "it uh what was 15025 and 2550 and 100", "start": 9538.04, "duration": 9.08 }, { "text": "combined through addition now is 125 100", "start": 9543.04, "duration": 6.439 }, { "text": "125 so pretty straightforward using", "start": 9547.12, "duration": 3.92 }, { "text": "techniques from weeks ago where we're", "start": 9549.479, "duration": 3.401 }, { "text": "just declaring a few new variables and", "start": 9551.04, "duration": 4.8 }, { "text": "doing some addition but wouldn't it be", "start": 9552.88, "duration": 5.32 }, { "text": "cool if I could do something like this", "start": 9555.84, "duration": 3.88 }, { "text": "wouldn't it be cool if I could just", "start": 9558.2, "duration": 4.079 }, { "text": "somehow not manually create my own Vault", "start": 9559.72, "duration": 4.84 }, { "text": "and do all of this annoying math up here", "start": 9562.279, "duration": 4.521 }, { "text": "what if I could just do Potter plus", "start": 9564.56, "duration": 4.96 }, { "text": "Weasley and get rid of all of this logic", "start": 9566.8, "duration": 5.36 }, { "text": "here like wouldn't it be nice if I", "start": 9569.52, "duration": 6.48 }, { "text": "overload the operator no we know as plus", "start": 9572.16, "duration": 6.48 }, { "text": "just like stir does just like list does", "start": 9576.0, "duration": 5.92 }, { "text": "to allow me to add two vaults together", "start": 9578.64, "duration": 6.08 }, { "text": "on the left and the right well it turns", "start": 9581.92, "duration": 5.399 }, { "text": "out in Python on and through operator", "start": 9584.72, "duration": 5.48 }, { "text": "overla there is a way to do just this if", "start": 9587.319, "duration": 4.96 }, { "text": "you consult the documentation there are", "start": 9590.2, "duration": 4.52 }, { "text": "there's this and so many other special", "start": 9592.279, "duration": 4.841 }, { "text": "methods that come with classes the third", "start": 9594.72, "duration": 5.12 }, { "text": "one we'll see here is this one here", "start": 9597.12, "duration": 5.4 }, { "text": "underscore uncore add underscore", "start": 9599.84, "duration": 4.4 }, { "text": "underscore and you'll see that it very", "start": 9602.52, "duration": 3.0 }, { "text": "generically is described in the", "start": 9604.24, "duration": 3.48 }, { "text": "documentation is working for any object", "start": 9605.52, "duration": 4.32 }, { "text": "be it a vault or a stir or a list or", "start": 9607.72, "duration": 3.88 }, { "text": "something else by convention it's going", "start": 9609.84, "duration": 3.559 }, { "text": "to take a first argument called self and", "start": 9611.6, "duration": 2.92 }, { "text": "then it's going to take some other", "start": 9613.399, "duration": 4.361 }, { "text": "argument by convention called Other Self", "start": 9614.52, "duration": 5.04 }, { "text": "in effect is going to be referring to", "start": 9617.76, "duration": 3.76 }, { "text": "whatever object is on the left of a plus", "start": 9619.56, "duration": 4.12 }, { "text": "sign other is going to be referring to", "start": 9621.52, "duration": 3.959 }, { "text": "whatever is on the right hand side of a", "start": 9623.68, "duration": 4.08 }, { "text": "plus sign thereby giving us a way of", "start": 9625.479, "duration": 4.96 }, { "text": "describing in code the operand on the", "start": 9627.76, "duration": 4.92 }, { "text": "left and the operand on the right of the", "start": 9630.439, "duration": 5.721 }, { "text": "operator Plus in between that is to say", "start": 9632.68, "duration": 5.44 }, { "text": "if I go back to VSS code here what I'm", "start": 9636.16, "duration": 5.119 }, { "text": "trying to do is Implement support for", "start": 9638.12, "duration": 5.56 }, { "text": "this well let me try without writing any", "start": 9641.279, "duration": 5.241 }, { "text": "other code just yet python a vault up", "start": 9643.68, "duration": 6.12 }, { "text": "high enter type error unsupported", "start": 9646.52, "duration": 7.12 }, { "text": "operand types for Vault and Vault that", "start": 9649.8, "duration": 6.2 }, { "text": "is to say python at this moment does not", "start": 9653.64, "duration": 4.52 }, { "text": "know what it means to add two vaults", "start": 9656.0, "duration": 3.8 }, { "text": "together right you and I might have an", "start": 9658.16, "duration": 3.319 }, { "text": "instinct probably want to combine the", "start": 9659.8, "duration": 4.08 }, { "text": "gallions and the sickles and the canuts", "start": 9661.479, "duration": 4.401 }, { "text": "respectively python doesn't know that it", "start": 9663.88, "duration": 3.399 }, { "text": "just knows that you have a new class", "start": 9665.88, "duration": 3.479 }, { "text": "called Vault but let's teach python to", "start": 9667.279, "duration": 4.721 }, { "text": "do this let me clear my terminal window", "start": 9669.359, "duration": 4.161 }, { "text": "let me scroll back up to the class", "start": 9672.0, "duration": 3.88 }, { "text": "itself where at the moment I only have", "start": 9673.52, "duration": 4.919 }, { "text": "two special methods in it and stir but", "start": 9675.88, "duration": 4.76 }, { "text": "let's add this third all right let me go", "start": 9678.439, "duration": 3.721 }, { "text": "into the class here and Define", "start": 9680.64, "duration": 3.44 }, { "text": "underscore uncore add underscore", "start": 9682.16, "duration": 4.319 }, { "text": "underscore and then specify its first", "start": 9684.08, "duration": 4.96 }, { "text": "parameter as self as before and then a", "start": 9686.479, "duration": 4.161 }, { "text": "second parameter for this particular", "start": 9689.04, "duration": 4.0 }, { "text": "method called by convention other now as", "start": 9690.64, "duration": 3.719 }, { "text": "always I could name those parameters", "start": 9693.04, "duration": 2.439 }, { "text": "anything I want but I'm going to stick", "start": 9694.359, "duration": 3.401 }, { "text": "with convention Here and Now inside of", "start": 9695.479, "duration": 4.241 }, { "text": "this method am I going to have to now", "start": 9697.76, "duration": 4.48 }, { "text": "add together the contents of two vaults", "start": 9699.72, "duration": 4.04 }, { "text": "well what two vaults well if we scroll", "start": 9702.24, "duration": 3.4 }, { "text": "down to our goal at hand the goal goal", "start": 9703.76, "duration": 3.639 }, { "text": "of course is to add this Vault plus this", "start": 9705.64, "duration": 3.6 }, { "text": "other Vault Potter plus Weasley", "start": 9707.399, "duration": 4.321 }, { "text": "respectively well it turns out in Python", "start": 9709.24, "duration": 4.32 }, { "text": "that when you do overload an operator", "start": 9711.72, "duration": 3.52 }, { "text": "like Plus what's going to happen", "start": 9713.56, "duration": 3.719 }, { "text": "automatically as soon as python sees", "start": 9715.24, "duration": 3.4 }, { "text": "that is it's going to call that", "start": 9717.279, "duration": 3.16 }, { "text": "underscore underscore ad underscore", "start": 9718.64, "duration": 3.799 }, { "text": "uncore method and it's going to pass", "start": 9720.439, "duration": 4.121 }, { "text": "into it two arguments whatever the", "start": 9722.439, "duration": 4.481 }, { "text": "operand is on the left Potter in this", "start": 9724.56, "duration": 4.48 }, { "text": "case and whatever the operand is on the", "start": 9726.92, "duration": 4.32 }, { "text": "right Weasley in this case and those", "start": 9729.04, "duration": 3.96 }, { "text": "values are going to get passed in as", "start": 9731.24, "duration": 4.56 }, { "text": "self and other respectively what that", "start": 9733.0, "duration": 4.24 }, { "text": "means is that we can access their", "start": 9735.8, "duration": 3.2 }, { "text": "contents up here in our implementation", "start": 9737.24, "duration": 3.6 }, { "text": "of AD as follows let me go ahead and", "start": 9739.0, "duration": 4.24 }, { "text": "Define a local variable called gallions", "start": 9740.84, "duration": 4.36 }, { "text": "and set that equal to for instance the", "start": 9743.24, "duration": 5.159 }, { "text": "sum of self dot gallions whatever's in", "start": 9745.2, "duration": 5.4 }, { "text": "uh Potter's vault in this case plus", "start": 9748.399, "duration": 4.08 }, { "text": "whatever is in Weasley's vault in this", "start": 9750.6, "duration": 4.36 }, { "text": "case which would be other. gallions let", "start": 9752.479, "duration": 5.761 }, { "text": "me do the same for sickles self. sickles", "start": 9754.96, "duration": 6.0 }, { "text": "plus other Doles and let me lastly do", "start": 9758.24, "duration": 6.079 }, { "text": "that for canuts so self. canuts Plus", "start": 9760.96, "duration": 4.96 }, { "text": "other. canuts", "start": 9764.319, "duration": 2.96 }, { "text": "but at the end of the day I'm going to", "start": 9765.92, "duration": 3.72 }, { "text": "need to return a brand new bigger Vault", "start": 9767.279, "duration": 4.281 }, { "text": "that contains all of those contents", "start": 9769.64, "duration": 3.92 }, { "text": "together and if we ultimately want to", "start": 9771.56, "duration": 4.4 }, { "text": "assign that bigger Vault to a variable", "start": 9773.56, "duration": 4.719 }, { "text": "like total here on the left we better", "start": 9775.96, "duration": 4.399 }, { "text": "indeed return a value from this ad", "start": 9778.279, "duration": 3.761 }, { "text": "method so I'm going to go ahead and give", "start": 9780.359, "duration": 4.401 }, { "text": "myself a brand new vault as by returning", "start": 9782.04, "duration": 4.359 }, { "text": "Capital vault which of course is going", "start": 9784.76, "duration": 4.04 }, { "text": "to call My Vault function into which I", "start": 9786.399, "duration": 3.96 }, { "text": "can now pass some of those", "start": 9788.8, "duration": 3.44 }, { "text": "initialization arguments well how many", "start": 9790.359, "duration": 3.401 }, { "text": "gallion sickles and canuts do I want", "start": 9792.24, "duration": 3.72 }, { "text": "this brand new Vault to contain well I", "start": 9793.76, "duration": 4.719 }, { "text": "want it to contain this many gallions", "start": 9795.96, "duration": 5.319 }, { "text": "this many sickles and this many canuts", "start": 9798.479, "duration": 4.361 }, { "text": "so ultimately what we're doing in this", "start": 9801.279, "duration": 3.921 }, { "text": "implementation of ad is adding together", "start": 9802.84, "duration": 4.76 }, { "text": "those gallion sickles and canuts passing", "start": 9805.2, "duration": 4.0 }, { "text": "them to the Vault function so that we", "start": 9807.6, "duration": 4.0 }, { "text": "get a brand new bigger Vault and return", "start": 9809.2, "duration": 5.56 }, { "text": "that Al together so now I've defined", "start": 9811.6, "duration": 5.52 }, { "text": "this new special method called add that", "start": 9814.76, "duration": 6.04 }, { "text": "should now just make Plus work for two", "start": 9817.12, "duration": 6.0 }, { "text": "vaults all right let's see let me run", "start": 9820.8, "duration": 4.12 }, { "text": "down to my terminal window python a", "start": 9823.12, "duration": 5.159 }, { "text": "vault high and hit enter and voila now", "start": 9824.92, "duration": 6.439 }, { "text": "we've implemented an overloaded operator", "start": 9828.279, "duration": 5.2 }, { "text": "plus to do what you and I as humans", "start": 9831.359, "duration": 3.601 }, { "text": "would hope would be the case when you", "start": 9833.479, "duration": 3.521 }, { "text": "add two vaults together but I've now", "start": 9834.96, "duration": 4.12 }, { "text": "written the code more specifically to", "start": 9837.0, "duration": 5.6 }, { "text": "teach python what it means concretely to", "start": 9839.08, "duration": 5.92 }, { "text": "add two vaults together and it's with", "start": 9842.6, "duration": 4.28 }, { "text": "very similar code in effect underneath", "start": 9845.0, "duration": 3.72 }, { "text": "the hood that python is doing this for", "start": 9846.88, "duration": 3.96 }, { "text": "two strings to concatenate them together", "start": 9848.72, "duration": 4.32 }, { "text": "to joining two lists into a new list", "start": 9850.84, "duration": 4.96 }, { "text": "with lists and so many other class as", "start": 9853.04, "duration": 6.48 }, { "text": "well any questions now on operator", "start": 9855.8, "duration": 6.559 }, { "text": "overloading or this example here how", "start": 9859.52, "duration": 5.32 }, { "text": "would you go about creating a function", "start": 9862.359, "duration": 7.561 }, { "text": "for adding a student and a vault for two", "start": 9864.84, "duration": 7.88 }, { "text": "two separate classes how would that be", "start": 9869.92, "duration": 5.04 }, { "text": "possible let me see what happens here I", "start": 9872.72, "duration": 4.2 }, { "text": "don't know off hand let's do this let's", "start": 9874.96, "duration": 3.56 }, { "text": "create a stir and see what happens if I", "start": 9876.92, "duration": 4.84 }, { "text": "add Potter plus a stir stir object yeah", "start": 9878.52, "duration": 4.879 }, { "text": "okay so it would work I'm just figuring", "start": 9881.76, "duration": 3.88 }, { "text": "this out as I go here Eric so just to re", "start": 9883.399, "duration": 3.641 }, { "text": "be clear what I did was I just changed", "start": 9885.64, "duration": 3.16 }, { "text": "Weasley to stir just to see what would", "start": 9887.04, "duration": 4.96 }, { "text": "happen when I add a vault plus a stir", "start": 9888.8, "duration": 6.04 }, { "text": "and it will work theoretically why", "start": 9892.0, "duration": 5.84 }, { "text": "because so long as the type of value on", "start": 9894.84, "duration": 6.68 }, { "text": "the left has an add method implemented", "start": 9897.84, "duration": 6.519 }, { "text": "other can be any type that you want you", "start": 9901.52, "duration": 4.879 }, { "text": "just have to decide in code what it's", "start": 9904.359, "duration": 3.761 }, { "text": "going to mean conceptually to add a", "start": 9906.399, "duration": 3.681 }, { "text": "vault plus a string which in this case", "start": 9908.12, "duration": 4.12 }, { "text": "probably doesn't make any sense at all", "start": 9910.08, "duration": 3.68 }, { "text": "but it's possible it's going to be the", "start": 9912.24, "duration": 3.64 }, { "text": "operand on the left and I'm inferring", "start": 9913.76, "duration": 3.599 }, { "text": "that I did not know the answer a moment", "start": 9915.88, "duration": 3.36 }, { "text": "ago I'm inferring that because what I", "start": 9917.359, "duration": 4.641 }, { "text": "got was an attribute error here on line", "start": 9919.24, "duration": 5.64 }, { "text": "11 because python did not like this", "start": 9922.0, "duration": 5.479 }, { "text": "other gallion didn't work but I could", "start": 9924.88, "duration": 4.72 }, { "text": "make it work by figuring something out", "start": 9927.479, "duration": 3.721 }, { "text": "really good question didn't know that", "start": 9929.6, "duration": 5.08 }, { "text": "one myself other questions on operator", "start": 9931.2, "duration": 5.92 }, { "text": "overloading can you define new operators", "start": 9934.68, "duration": 5.4 }, { "text": "in Python I don't think so there is a", "start": 9937.12, "duration": 6.08 }, { "text": "very long but precise list of operators", "start": 9940.08, "duration": 5.279 }, { "text": "that you can overload I do not not", "start": 9943.2, "duration": 4.56 }, { "text": "believe you can assign arbitrary", "start": 9945.359, "duration": 5.04 }, { "text": "characters to be operators in Python uh", "start": 9947.76, "duration": 4.32 }, { "text": "let me defer to Carter in the chat to", "start": 9950.399, "duration": 3.0 }, { "text": "revoke okay I'm seeing two of my", "start": 9952.08, "duration": 3.239 }, { "text": "colleagues are saying no not possible so", "start": 9953.399, "duration": 3.281 }, { "text": "I'm going to go with my first instinct", "start": 9955.319, "duration": 3.201 }, { "text": "no otherwise that'd be kind of cool you", "start": 9956.68, "duration": 4.04 }, { "text": "could make Emoji do whatever you want to", "start": 9958.52, "duration": 4.28 }, { "text": "how about one final question on operator", "start": 9960.72, "duration": 4.24 }, { "text": "overloading is that the only operation", "start": 9962.8, "duration": 5.679 }, { "text": "you can do uh is a far as like can you", "start": 9964.96, "duration": 5.88 }, { "text": "do a subtraction as well you can you can", "start": 9968.479, "duration": 5.401 }, { "text": "do so many others let me um if Carter", "start": 9970.84, "duration": 5.72 }, { "text": "you don't mind pulling up this URL here", "start": 9973.88, "duration": 4.64 }, { "text": "so this link here special method names", "start": 9976.56, "duration": 4.44 }, { "text": "in today's slides you'll see a long list", "start": 9978.52, "duration": 3.959 }, { "text": "of all of The Operators that you can", "start": 9981.0, "duration": 3.439 }, { "text": "overload you can do less than equals", "start": 9982.479, "duration": 4.321 }, { "text": "than plus equals minus equals pretty", "start": 9984.439, "duration": 4.241 }, { "text": "much any symbol you've seen me type on", "start": 9986.8, "duration": 3.519 }, { "text": "the screen can be overloaded in the", "start": 9988.68, "duration": 3.52 }, { "text": "context of", "start": 9990.319, "duration": 4.761 }, { "text": "classes so even though today we focused", "start": 9992.2, "duration": 4.84 }, { "text": "entirely on object-oriented programming", "start": 9995.08, "duration": 3.08 }, { "text": "this is a technique that we've been", "start": 9997.04, "duration": 2.92 }, { "text": "using really since the first week of the", "start": 9998.16, "duration": 3.72 }, { "text": "class because indeed those ins those", "start": 9999.96, "duration": 4.439 }, { "text": "stirs those floats those lists those", "start": 10001.88, "duration": 4.28 }, { "text": "dictionaries and so much more we're", "start": 10004.399, "duration": 3.281 }, { "text": "already underneath the hood this whole", "start": 10006.16, "duration": 4.279 }, { "text": "time classes and objects thereof but you", "start": 10007.68, "duration": 4.32 }, { "text": "now as a programmer have the ability to", "start": 10010.439, "duration": 3.481 }, { "text": "create your own classes with your own", "start": 10012.0, "duration": 3.64 }, { "text": "instance or class variables with your", "start": 10013.92, "duration": 3.68 }, { "text": "own instance or class methods with your", "start": 10015.64, "duration": 4.4 }, { "text": "own properties and even with your own", "start": 10017.6, "duration": 4.64 }, { "text": "custom behavior for operators so", "start": 10020.04, "duration": 4.359 }, { "text": "ultimately you can absolutely continue", "start": 10022.24, "duration": 5.039 }, { "text": "using those simple tuples or lists or", "start": 10024.399, "duration": 4.761 }, { "text": "those dictionaries or other structures", "start": 10027.279, "duration": 3.881 }, { "text": "as well but object-oriented programming", "start": 10029.16, "duration": 3.6 }, { "text": "and with it classes and now these", "start": 10031.16, "duration": 3.279 }, { "text": "objects is just another tool in your", "start": 10032.76, "duration": 3.88 }, { "text": "toolkit and dare say as your code gets", "start": 10034.439, "duration": 4.321 }, { "text": "more sophisticated and your problems get", "start": 10036.64, "duration": 3.88 }, { "text": "bigger you'll find that being able to", "start": 10038.76, "duration": 3.88 }, { "text": "model these real world or even fantasy", "start": 10040.52, "duration": 4.6 }, { "text": "world entities with classes and related", "start": 10042.64, "duration": 4.48 }, { "text": "data and functionality will ultimately", "start": 10045.12, "duration": 3.84 }, { "text": "just allow you to Define code that's not", "start": 10047.12, "duration": 4.68 }, { "text": "just correct but ever well designed as", "start": 10048.96, "duration": 6.6 }, { "text": "well this was", "start": 10051.8, "duration": 3.76 }, { "text": "cs50", "start": 10059.96, "duration": 3.0 } ]