<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Oop on Margrop Blog</title>
    <link>https://blog.margrop.net/en/tag/oop/</link>
    <description>Recent content in Oop on Margrop Blog</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-US</language>
    <lastBuildDate>Thu, 04 Mar 2021 22:23:55 +0800</lastBuildDate>
    <atom:link href="https://blog.margrop.net/en/tag/oop/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Python3 object-oriented programming</title>
      <link>https://blog.margrop.net/en/post/python3-oop/</link>
      <pubDate>Thu, 04 Mar 2021 22:23:55 +0800</pubDate>
      <guid>https://blog.margrop.net/en/post/python3-oop/</guid>
      <description>Object-oriented programming Access restrictions Private variables start with __ class Student(object): def __init__(self, name, score): self.name = name self.score = score def print_score(self): print(&amp;#39;%s: %s&amp;#39; % (self.name, self.score)) Inheritance and polymorphism Inheritance: Dog inherits from Animal class Student(object): def __init__(self, name, score): self.__name = name self.__score = score def print_score(self): print(&amp;#39;%s: %s&amp;#39; % (self.__name, self.__score)) Get object information Basic object types Object type of a function or class Type checking Reflection: use dir() to get all properties and methods of an object Reflection: getattr(), setattr(), and hasattr() Interfaces and duck typing class Animal(object): def run(self): print(&amp;#39;Animal is running.</description>
    </item>
  </channel>
</rss>
