main.py 文件源码

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

项目:silly 作者: classam 项目源码 文件源码
def capitalize_argument(func):
    """
    Wraps a function that returns a string, adding the 'capitalize' argument.

    >>> capsified_fn = capitalize_argument(lambda *args, **kwargs: "what in the beeswax is this?")
    >>> capsified_fn()
    'what in the beeswax is this?'
    >>> capsified_fn(capitalize=True)
    'What In The Beeswax Is This?'

    """
    @six.wraps(func)
    def wrapped(*args, **kwargs):
        if "capitalize" in kwargs and kwargs['capitalize']:
            return func(*args, **kwargs).title()
        else:
            return func(*args, **kwargs)
    return wrapped
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号