utils.py 文件源码

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

项目:plotnine 作者: has2k1 项目源码 文件源码
def alias(name, class_object):
    """
    Create an alias of a class object

    The objective of this method is to have
    an alias that is Registered. i.e If we have

        class_b = class_a

    Makes `class_b` an alias of `class_a`, but if
    `class_a` is registered by its metaclass,
    `class_b` is not. The solution

        alias('class_b', class_a)

    is equivalent to:

        class_b = class_a
        Register['class_b'] = class_a
    """
    module = inspect.getmodule(class_object)
    module.__dict__[name] = class_object
    if isinstance(class_object, Registry):
        Registry[name] = class_object
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号