A Hundred Days of Code, Day 017 - Python, Advanced Objects, Done!

And we are done with objects! This course finally gave me what I was looking for all these months. The ability to think of and reason about Python, so that I can then think of and reason about, how to build my own programs. Notes Abstract base classes Sounds all high and mighty, but does something pretty logical and simple Helps me test if my object is of a generic (of sorts) type....

July 25, 2020 · Mario Jason Braganza

A Hundred Days of Code, Day 016 - Python, Advanced Objects.

Started up with Python Objects today. This seems like a long, hard one. Here’s hoping I learn lots. Knowing Reuven, I know I will. Notes Part 1, Advanced Methods. This section focuses on the dunder methods in Python. By default objects are not equal to other objects even they they are from the same class, with the same attributes and methods. We could implement our own equals method though. The point being, we need to be intentional and methodical, when we design and implement our classses Static methods are plain old functions that I write in my class for use by both the class and the instance....

July 24, 2020 · Mario Jason Braganza

A Hundred Days of Code, Day 005 - Magic Methods and Winding Up OOP

Done with Reuven Lerner’s OOP basics Notes len does the right thing across multiple types of objects. it counts characters in a string, elements in a list, and key-value pairs in a dictionary. how does it know how to do that? that is because len uses a magic method (methods that have a __ for a prefix and suffix) len uses the __len__ method which i can use in my own classes, to implement a len method for my classes If I choose to do so, I need to realise what those underlying methods expect to return and return the same type in my classes....

July 12, 2020 · Mario Jason Braganza

A Hundred Days of Code, Day 004 - Class Attributes and Inheritance

Learnt about Class Attributes and Inheritance, today. Notes The way we write functions/methods and define classes might look similar, class CrazyTalk(object): and def how_now_brown_cow(): The way they behave/execute, though is wildly different. Classes run / spring to life as soon as the program launches. Functions don’t, unless they are called. Realised that objects are containers. What you can do with the object depends on what is in it. Does it hold a dictionary with various methods to modify it?...

July 11, 2020 · Mario Jason Braganza

A Hundred Days of Code, Day 003 - Methods

Learnt about methods today. Notes follow … My understanding about methods? They are functions in classes that help me manipulate the data the objects contain when they are created. I have been using something them subconsciously all along. The __init__ method, that is called/run automatically every time an object is created. Aha A nice way to unpack the .notation i use Let’s say I have a class SquareNumbers that has a function (method) ­— x2 — that will, you know, square a number....

July 10, 2020 · Mario Jason Braganza

A Hundred Days of Code, Day 002 - Basic Exercises

Did a few exercises today. They were simple. Create a few classes, change them, modify them, use a list as an attribute and so on. In a couple of ways, this was just what I needed. One, I had an extremely busy day at work, and so I did not have the brain power to do anything complex, so I needed the bar really low any way. And two, I’ve realised, that I have always tried to just read a book and then leap mountains....

July 9, 2020 · Mario Jason Braganza

A Hundred Days of Code, Day 001 - Beginning With Classes

Notes I’ve taken from the videos I watched, today. This is my attempt at Feynman-ing (below), what I learnt so far. Classes and Object Oriented Programming started to come together for me, when I saw Kushal using them. To use my father’s carpentry analogy, I could in theory just hammer nails into wood to join them. But to make a really strong joint, I could use other methods. I could screw pieces of wood together, which is markedly better than just nailing them....

July 8, 2020 · Mario Jason Braganza