Day 5 of 100 Days

Day 5: 2018/04/30

Today’s Topic: Python: A byte of python

Today’s Progress: Start from “Class and Object variables” (page 105) and finished oop. I also started input/output section, and finished first homework (palindrome with punctuation). I stopped before I jump to “Files input output” (page 113)

Thoughts: Today I revisit the concept of “classmethod” and “staticmethod”, and decorators (@), which apparently I was not very familiar with before. There are few conventions that I don’t really remember to do. I usually forget: class subclass(superclass), or in the methods I should always pass in self as the first argument. These are due to the fact I don’t write enough code, and I am not used to this. (which makes this 100 days of learning more meaningful).
Input and output is not hard for me (especially the part where you have user input).


  • class variable belongs to the whole class
  • object variable is bind to the instance only
  • in instance, you may reference your class as self.__class__
    so “Robot.population” can be written as “self.__class__.population” (assuming self is now an instance of Robot class)
  • @classmethod (and @staticmethod)
  • all data are public. Use __private to make data in the class “private”
  • super class vs. sub class
  • class subclass(superclass) ← inheritance
  • remember to always initialize (__init__)
  • remember to always add “self” in the class methods
  • If you define __init__ in the subclass, you have to call superclass.__init__(…) to make sure the superclass initialization is done;
  • On the other hand, if you don’t define __init__, the superclass.__init__(…) is called.

Link to work: Link to my own Google drive to show my progress here.

This entry was posted in 象哥的學習筆記 Study Notes and tagged . Bookmark the permalink.

Leave a Reply