python Object Oriented Programming

python 知识点整理(五)

本文只是对python部分知识点进行学习和整理
本篇主要是针对python的Object Oriented Programming的总结

object/class/inheritance

objects

  • object: An object has a unique identity, state, and behaviours
  • In Python, everything is an object: number, string, etc
  • can use id() and type() to get information about an object
  • ID位置一般不会改变
  • 数据类型会根据input进行决定
  • A variable in Python is actually a reference to an object.变量是对对象的引用

class

class name
data fields private/public

  • private data fields are defined with two leading underscores(__). The same as a private

method
methods

  • A class provides a special method, init(), which is called initializer(给定默认初始值)
  • Initializer is invoked when an instance of the class is created

inheritance

Object-oriented programming (OOP) allows you to define new classes from existing classes. This is called inheritance

Polymorphism and dynamic binding

  • Polymorphism means that an object of a subclass can be passed to a parameter of a superclass type
  • 多态性意味着子类的对象可以传递给超类类型的参数
  • Python decides which method is invoked at runtime. This is known as dynamic binding
  • Python决定在运行时调用哪个方法。这就是所谓的动态绑定

recursion 迭代

  • Linear Recursion
  • If a recursive function is designed so that each invocation of the body makes at most one new recursive call, this is known as linear recursion
  • Multiple recursion
  • When a function makes two or more recursive calls, we say that it uses multiple recursion
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值