当前位置: 首页>>代码示例>>Python>>正文


Python object.__new__方法代码示例

本文整理汇总了Python中future.builtins.object.__new__方法的典型用法代码示例。如果您正苦于以下问题:Python object.__new__方法的具体用法?Python object.__new__怎么用?Python object.__new__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在future.builtins.object的用法示例。


在下文中一共展示了object.__new__方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __new__

# 需要导入模块: from future.builtins import object [as 别名]
# 或者: from future.builtins.object import __new__ [as 别名]
def __new__(cls, year, month=None, day=None):
        """Constructor.

        Arguments:

        year, month, day (required, base 1)
        """
        if (isinstance(year, bytes) and len(year) == 4 and
            1 <= year[2] <= 12 and month is None):  # Month is sane
            # Pickle support
            self = object.__new__(cls)
            self.__setstate(year)
            return self
        _check_date_fields(year, month, day)
        self = object.__new__(cls)
        self._year = year
        self._month = month
        self._day = day
        return self

    # Additional constructors 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:23,代码来源:datetime.py

示例2: __new__

# 需要导入模块: from future.builtins import object [as 别名]
# 或者: from future.builtins.object import __new__ [as 别名]
def __new__(cls, hour=0, minute=0, second=0, microsecond=0, tzinfo=None):
        """Constructor.

        Arguments:

        hour, minute (required)
        second, microsecond (default to zero)
        tzinfo (default to None)
        """
        self = object.__new__(cls)
        if isinstance(hour, bytes) and len(hour) == 6:
            # Pickle support
            self.__setstate(hour, minute or None)
            return self
        _check_tzinfo_arg(tzinfo)
        _check_time_fields(hour, minute, second, microsecond)
        self._hour = hour
        self._minute = minute
        self._second = second
        self._microsecond = microsecond
        self._tzinfo = tzinfo
        return self

    # Read-only field accessors 
开发者ID:remg427,项目名称:misp42splunk,代码行数:26,代码来源:datetime.py


注:本文中的future.builtins.object.__new__方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。