zoukankan      html  css  js  c++  java
  • python之类的属性

    class type(object)

    With one argument, return the type of an object. The return value is a type object. The isinstance() built-in function is recommended for testing the type of an object.

    意思是当传递的参数个数为1时,返回的是这个对象的类型

    class type(name, bases, dict)

    With three arguments, return a new type object. This is essentially a dynamic form of the class statement. The name string is the class name and becomes the __name__ attribute; the bases tuple itemizes the base classes and becomes the __bases__ attribute; and the dict dictionary is the namespace containing definitions for class body and becomes the __dict__ attribute. For example, the following two statements create identical type objects:

    当传参是三个的时候,返回的是一个新类型的对象。这个本质是动态声明类的一种形式,包括类的名字由名字属性,基础类属性,以及一个字典目录包含这个类的定义。

    >>> class X(object):
    ...     a = 1
    ...
    >>> X = type('X', (object,), dict(a=1))

    >>> X.__dict__
    dict_proxy({'a': 1, '__dict__': <attribute '__dict__' of 'X' objects>, '__module__': '__main__', '__weakref__': <attribute '__weakref__' of 'X' objects>, '__doc__': None})

  • 相关阅读:
    [JSOI2008]Blue Mary开公司[李超线段树]
    线段树分治
    满汉全席[2-SAT]
    「一本通 3.5 练习 5」和平委员会
    2-SAT问题
    2019/04/06 BJ省选模拟DAY1
    构造题【随时更
    文本编辑器vim/vi——命令模式
    指令——cat
    指令——history
  • 原文地址:https://www.cnblogs.com/passion-hzhang/p/5992053.html
Copyright © 2011-2022 走看看