python3 面向对象__类的内置属性与方法的实例代码

yipeiwu_com5年前Python基础

0.object类源码

class object:
  """ The most base type """
  def __delattr__(self, *args, **kwargs): # real signature unknown
    """ Implement delattr(self, name). """
    pass
  def __dir__(self): # real signature unknown; restored from __doc__
    """
    __dir__() -> list
    default dir() implementation
    """
    return []
  def __eq__(self, *args, **kwargs): # real signature unknown
    """ Return self==value. """
    pass
  def __format__(self, *args, **kwargs): # real signature unknown
    """ default object formatter """
    pass
  def __getattribute__(self, *args, **kwargs): # real signature unknown
    """ Return getattr(self, name). """
    pass
  def __ge__(self, *args, **kwargs): # real signature unknown
    """ Return self>=value. """
    pass
  def __gt__(self, *args, **kwargs): # real signature unknown
    """ Return self>value. """
    pass
  def __hash__(self, *args, **kwargs): # real signature unknown
    """ Return hash(self). """
    pass
  def __init_subclass__(self, *args, **kwargs): # real signature unknown
    """
    This method is called when a class is subclassed.
    The default implementation does nothing. It may be
    overridden to extend subclasses.
    """
    pass
  def __init__(self): # known special case of object.__init__
    """ Initialize self. See help(type(self)) for accurate signature. """
    pass
  def __le__(self, *args, **kwargs): # real signature unknown
    """ Return self<=value. """
    pass
  def __lt__(self, *args, **kwargs): # real signature unknown
    """ Return self<value. """
    pass
  @staticmethod # known case of __new__
  def __new__(cls, *more): # known special case of object.__new__
    """ Create and return a new object. See help(type) for accurate signature. """
    pass
  def __ne__(self, *args, **kwargs): # real signature unknown
    """ Return self!=value. """
    pass
  def __reduce_ex__(self, *args, **kwargs): # real signature unknown
    """ helper for pickle """
    pass
  def __reduce__(self, *args, **kwargs): # real signature unknown
    """ helper for pickle """
    pass
  def __repr__(self, *args, **kwargs): # real signature unknown
    """ Return repr(self). """
    pass
  def __setattr__(self, *args, **kwargs): # real signature unknown
    """ Implement setattr(self, name, value). """
    pass
  def __sizeof__(self): # real signature unknown; restored from __doc__
    """
    __sizeof__() -> int
    size of object in memory, in bytes
    """
    return 0
  def __str__(self, *args, **kwargs): # real signature unknown
    """ Return str(self). """
    pass
  @classmethod # known case
  def __subclasshook__(cls, subclass): # known special case of object.__subclasshook__
    """
    Abstract classes can override this to customize issubclass().
    This is invoked early on by abc.ABCMeta.__subclasscheck__().
    It should return True, False or NotImplemented. If it returns
    NotImplemented, the normal algorithm is used. Otherwise, it
    overrides the normal algorithm (and the outcome is cached).
    """
    pass
  __class__ = None # (!) forward: type, real value is ''
  __dict__ = {}
  __doc__ = ''
  __module__ = ''

1.内置属性说明

①__class__:说明对象处于模块中的哪一个类

②[类名].__dict__:打印类的所有属性与方法(包括继承自基类的属性和方法)(包括内置属性和方法)

   [对象].__dict__:打印对象的所有属性(私有和公有)

总结

以上所述是小编给大家介绍的python3 面向对象__类的内置属性与方法的实例代码,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对【听图阁-专注于Python设计】网站的支持!

相关文章

Python提示[Errno 32]Broken pipe导致线程crash错误解决方法

本文实例讲述了Python提示[Errno 32]Broken pipe导致线程crash错误解决方法。分享给大家供大家参考。具体方法如下: 1. 错误现象 ThreadingHTTPS...

Python模块搜索路径代码详解

简述 由于某些原因,在使用 import 时,Python 找不到相应的模块。这时,解释器就会发牢骚 - ImportError。 那么,Python 如何知道在哪里搜索模块的路径呢?...

python实现字符串加密 生成唯一固定长度字符串

背景 有时候爬虫爬过的url需要进行指纹核对,比如Scrapy就是进行指纹核对,如果是指纹重复则不再爬取。当然在入库的时候我还是需要做一次核对,否则如果爬虫有漏掉,进入数据库就不合适了。...

Python3.6+Django2.0以上 xadmin站点的配置和使用教程图解

Python3.6+Django2.0以上 xadmin站点的配置和使用教程图解

1. xadmin的介绍 django自带的admin站点虽然功能强大,但是界面不是很好看。而xadmin界面好看,功能更强大,并完全支持Bootstrap主题模板。xadmin内置了丰...

浅析Python编写函数装饰器

编写函数装饰器 本节主要介绍编写函数装饰器的相关内容。 跟踪调用 如下代码定义并应用一个函数装饰器,来统计对装饰的函数的调用次数,并且针对每一次调用打印跟踪信息。 class tr...