python __builtins__ classmethod类 (11)
11、'classmethod', 修饰符对应的函数不需要实例化,不需要 self 参数,但第一个参数需要是表示自身类的 cls 参数,可以来调用类的属性,类的方法,实例化对象等。
class classmethod(object)
| classmethod(function) -> method
|
| Convert a function to be a class method. # 将一个函数转换成类方法
|
| A class method receives the class as implicit first argument,
一个类方法,接收类作为隐式参数
| just like an instance method receives the instance.
就像一个实例方法接收实例对象
| To declare a class method, use this idiom:
|
| class C:
| @classmethod
| def f(cls, arg1, arg2, ...):
| ...
|
| It can be called either on the class (e.g. C.f()) or on an instance
| (e.g. C().f()). The instance is ignored except for its class.
可以用类对象调用f函数,也可以实例对象调用f函数。
| If a class method is called for a derived class, the derived class
| object is passed as the implied first argument.
|
| Class methods are different than C++ or Java static methods.
| If you want those, see the staticmethod builtin.
|
| Methods defined here:
|
| __get__(self, instance, owner, /)
| Return an attribute of instance, which is of type owner.
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| __new__(*args, **kwargs) from builtins.type
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
|
| __func__
|
| __isabstractmethod__
python __builtins__ classmethod类 (11)的更多相关文章
- python __builtins__ staticmethod类 (64)
64.'staticmethod', 返回静态方法 class staticmethod(object) | staticmethod(function) -> method | | Conve ...
- python __builtins__ memoryview类 (46)
46.'memoryview', 返回给定参数的内存查看对象(Momory view).所谓内存查看对象,是指对支持缓冲区协议的数据进行包装,在不需要复制对象基础上允许Python代码访问. cla ...
- python __builtins__ help类 (32)
32.'help', 接收对象作为参数,更详细地返回该对象的所有属性和方法 class _Helper(builtins.object) | Define the builtin 'help'. | ...
- python __builtins__ float类 (25)
25.'float', 用于将整数和字符串转换成浮点数. class float(object) | float(x) -> floating point number | | Convert ...
- python __builtins__ bool类 (6)
6.'bool', 函数用于将给定参数转换为布尔类型,如果没有参数,返回 False. class bool(int) # 继承于int类型 | bool(x) -> bool # 创建boo ...
- python __builtins__ zip类 (71)
71.'zip' , 函数用于将可迭代的对象作为参数,将对象中对应的元素打包成一个个元组,然后返回由这些元组组成的列表.如果各个迭代器的元素个数不一致,则返回列表长度与最短的对象相同,利用 * 号操作 ...
- python __builtins__ type类 (69)
69.'type', 返回对象类型 class type(object) | type(object_or_name, bases, dict) | type(object) -> the ob ...
- python __builtins__ tuple类 (68)
68.'tuple', 转换为元组类型 class tuple(object) | tuple() -> empty tuple | tuple(iterable) -> tuple in ...
- python __builtins__ str类 (65)
65.'str', 字节转换成字符串.第一个传入参数是要转换的字节,第二个参数是按什么编码转换成字符串 class str(object) | str(object='') -> str | s ...
随机推荐
- LeanCloud SDK 中秒杀70%问题的调试方法
非常多同学在LeanCloud上遇到的不少问题,事实上能够自我解决的,如今介绍一下LeanCloud上的调试方法. LeanCloud 是通过 REST API来进行前后端分离的.这意味着当出现故障的 ...
- weex stream 方法封装
1.封装 api.js // 配置API接口地址 const baseUrl = 'http://www.kuitao8.com/'; // 引入 弹窗组件 var modal = weex.requ ...
- Intel HEX文件解析
近期有一个需求就是为Arduino开发板做一个基于蓝牙的无线烧录程序.眼下的Arduino程序都是通过USB线连接到电脑的主机上,实际的传输过程是基于USB协议的,这个过程还是比較麻烦的.由于每次的编 ...
- Intel processor brand names-Xeon,Core,Pentium,Celeron----Atom
http://en.wikipedia.org/wiki/Intel_atom Intel Atom From Wikipedia, the free encyclopedia (Redirect ...
- iOS 相似淘宝商品详情查看翻页效果的实现
基本思路: 1.设置一个 UIScrollView 作为视图底层,而且设置分页为两页 2.然后在第一个分页上加入一个 UITableView 而且设置表格可以上提载入(上拉操作即为让视图滚动到下一页) ...
- configuration类详解
hadoop中,组件配置是由Hadoop的Configuration的一个实例实现.(在源码包的org.apache.hadoop.conf中可以找到)先上个类图:这只是部分的,Configuraat ...
- JavaScript 实现块级作用域
(function(){ 块级作用域: })();
- 小程序多级下拉菜单demo
小程序多级下拉菜单demo - CSDN博客 https://blog.csdn.net/github_39371177/article/details/80251211
- [RK3399][Android7.1] 调试笔记 --- 模块编译32位动态库【转】
本文转载自:http://blog.csdn.net/kris_fei/article/details/78923784 Platform: RK3399 OS: Android 7.1 Board: ...
- CentOS/Ubuntu安装GLIBCXX3.4.21
经过测试“GLIBCXX3.4.21 not find”这篇博文解决了我的问题. 以下是安装步骤: 一.首先查看当前gcc版本 strings /usr/lib/x86_64_linux-gun/ ...