zoukankan      html  css  js  c++  java
  • python note of class

    reference: https://www.zhihu.com/question/27699413/answer/267906889

    摘要:

    我们在描述一个真实对象(物体)时包括两个方面:
    它可以做什么(行为)
    它是什么样的(属性或特征)
    结论:对象=属性(特征)+方法(行为)
    相同属性和方法的对象归为一个类(class)

    
    
    reference:https://www.codementor.io/sheena/essential-python-interview-questions-du107ozr6#

    class
    A(object): def go(self): print("go A go!") def stop(self): print("stop A stop!") def pause(self): raise Exception("Not Implemented") class B(A): def go(self): super(B, self).go() print("go B go!") class C(A): def go(self): super(C, self).go() print("go C go!") def stop(self): super(C, self).stop() print("stop C stop!") class D(B,C): def go(self): super(D, self).go() print("go D go!") def stop(self): super(D, self).stop() print("stop D stop!") def pause(self): print("wait D wait!") class E(B,C): pass a = A() b = B() c = C() d = D() e = E() # specify output from here onwards a.go() b.go() c.go() d.go() e.go() a.stop() b.stop() c.stop() d.stop() e.stop() a.pause() b.pause() c.pause() d.pause() e.pause() # output: a.go() # go A go! b.go() # go A go! # go B go! c.go() # go A go! # go C go! d.go() # go A go! # go C go! # go B go! # go D go! e.go() # go A go! # go C go! # go B go! a.stop() # stop A stop! b.stop() # stop A stop! c.stop() # stop A stop! # stop C stop! d.stop() # stop A stop! # stop C stop! # stop D stop! e.stop() # stop A stop! a.pause() # ... Exception: Not Implemented b.pause() # ... Exception: Not Implemented c.pause() # ... Exception: Not Implemented d.pause() # wait D wait! e.pause() # ...Exception: Not Implemented
  • 相关阅读:
    使用命令行创建制作 MACOS HIGH SIERRA 正式版 USB 安装盘
    IONIC2/3解决文本框获取焦点的问题
    一步一步实现IONIC2/3 热更新
    IONIC打包安卓遇到COM.ANDROID.SUPPORT:SUPPORT-V4错误的解决办法
    js hoisting
    js立即执行函数
    关于js sort排序方法
    js基础--substr()和substring()的区别
    关于align-items和align-content的区别和使用场景
    关于ionic开发中遇到的坑与总结
  • 原文地址:https://www.cnblogs.com/vickey-wu/p/7067902.html
Copyright © 2011-2022 走看看