How can I make a deepcopy of a function in Python?

后端 未结 6 955
我在风中等你
我在风中等你 2020-12-01 14:13

I would like to make a deepcopy of a function in Python. The copy module is not helpful, according to the documentation, which says:

This mo

6条回答
  •  青春惊慌失措
    2020-12-01 14:56

    from functools import partial
    
    def a():
        """Returns 1"""
        return 1
    
    b = partial(a)
    b.__doc__ = """Returns 1, OR DOES IT!"""
    
    print help(a)
    print help(b)
    

    Wrap it as a partial?

提交回复
热议问题