Does anybody know if it is possible to link a function1.__doc__
to a function2.__doc__
without writting it 2 times ?
For example I tried something like:
def function1(): """This is my function1 doc ! """ pass def function2(): __doc__ = function1.__doc__ pass >>> help(function2) >>> 'This is my function1 doc !'
The last line is what I would like to have.
Thanks ! :)
Advertisement
Answer
you can just assign it at after you define the function.
def function1(): """This is my function1 doc ! """ pass def function2(): pass function2.__doc__ = function1.__doc__
Since a function is just an object in python with attributes, you can change the attributes to what you want.