bit_enum.py 文件源码

python
阅读 32 收藏 0 点赞 0 评论 0

项目:slider 作者: llllllllll 项目源码 文件源码
def pack(cls, **kwargs):
        """Pack a bitmask from explicit bit values.

        Parameters
        ----------
        kwargs
            The names of the fields and their status. Any fields not explicitly
            passed will be set to False.

        Returns
        -------
        bitmask : int
            The packed bitmask.
        """
        members = cls.__members__
        try:
            return reduce(
                op.and_,
                (members[k] * bool(v) for k, v in kwargs.items()),
            )
        except KeyError as e:
            raise TypeError('{e} is not a member of {cls.__qualname__}')
评论列表


问题


面经


文章

微信
公众号

扫码关注公众号