zoukankan      html  css  js  c++  java
  • python中property(lambda self: object())简单解释

    最后4行lambda。问题是:如何运作?它们的含义和结果是什么?您能否以简单的方式显示该声明的示例?现在谢谢!

    class error(Exception):
        """ Base class for I/O related errors. """
        def __init__(self, *args, **kwargs): # real signature unknown
            pass
    
        @staticmethod # known case of __new__
        def __new__(S, *more): # real signature unknown; restored from __doc__
            """ T.__new__(S, ...) -> a new object with type S, a subtype of T """
            pass
    
        def __reduce__(self, *args, **kwargs): # real signature unknown
            pass
    
        def __str__(self): # real signature unknown; restored from __doc__
            """ x.__str__() <==> str(x) """
            pass
    
        characters_written = property(lambda self: object()) # default
        errno = property(lambda self: object()) # default
        filename = property(lambda self: object()) # default
        strerror = property(lambda self: object()) # default
    

    1个

    property是内置的。通常用作装饰器。该代码与此等效,可能看起来更加熟悉:

    class error(Exception):
        #...
        @property
        def characters_written(self):
            return object()
    
        @property
        def errno(self):
            return object()
    
        @property
        def filename(self):
            return object()
    
        @property
        def strerror(self):
            return object()
    
  • 相关阅读:
    js正则表达式——数字校验
    php curl cookie 读写
    Java遍历所有网卡打印对应IP
    mysql 查看数据库大小
    执行mvn 报错 source-1.5 中不支持 diamond运算符
    php开学之环境搭建
    ubuntu漂亮主题
    CleanAop使用笔记
    python学习笔记(五)
    python学习笔记(四)
  • 原文地址:https://www.cnblogs.com/sky-ai/p/12751180.html
Copyright © 2011-2022 走看看