zoukankan      html  css  js  c++  java
  • Python中的"Special Method"

    • The first thing to know about special methods is that they are meant to be called by the Python interpreter, and not by you. You don’t write my_object.len(). You write len(my_object) and, if my_object is an instance of a user-defined class, then Python calls the len instance method you implemented.

    • More often than not, the special method call is implicit. For example, the statement for i in x: actually causes the invocation of iter(x), which in turn may call x.iter() if that is available.

    • Avoidcreatingarbitrary,customattributeswiththe__foo__syntaxbecausesuchnames may acquire special meanings in the future, even if they are unused today.

  • 相关阅读:
    Java 学习资料
    01 html5
    vscode 插件推荐
    08 css高级
    07 css定位
    06 css布局浮动
    05 css盒子
    04 css复合选择器 标签 行高
    03 css字体样式
    02 css基础选择器
  • 原文地址:https://www.cnblogs.com/yaos/p/7103096.html
Copyright © 2011-2022 走看看