case.py 文件源码

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

项目:adt 作者: llllllllll 项目源码 文件源码
def __init__(self, constructors, name, *args, **kwargs):
        args = tuple(map(self._unwrap_name, args))
        kwargs = valmap(self._unwrap_name, kwargs)
        already_bound = {}
        for n, arg in enumerate(args):
            if arg in already_bound:
                raise TypeError(
                    'argument %r at position %d is already bound to the'
                    ' positional argument at index %d' % (
                        arg,
                        n,
                        already_bound[arg],
                    ),
                )
            already_bound[arg] = n

        for k, arg in kwargs.items():
            if arg in already_bound:
                loc = already_bound[arg]
                raise TypeError(
                    'argument %r at keyword %s is already bound to the %s' % (
                        arg,
                        k,
                        ('positional argument at index %d' % loc)
                        if isinstance(loc, int) else
                        ('keyword argument %r' % loc),
                    ),
                )

        super().__init__(constructors, name, *args, **kwargs)
        del constructors[name]
        self._constructors = constructors
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号