Python - How Does One Include A Variable In The Doc String?
I'm using the cmd module. there's a command that I'd like to document like this: def do_this(self,arg) 'this command accepts these values {values}'.format(values='legal values'
Solution 1:
Changing the docstring afterwards (by assigning to do_this.__doc__
) is the only way.
Or if you want it to look nicer, you can use a decorator - but it still assigns to do_this.__doc__
.
defdoc(docstring):
defdocument(func):
func.__doc__ = docstring
return func
return document
@doc("this command accepts these values: {values}".format(values=[1, 2, 3])
def do_this(self, arg):
pass
Post a Comment for "Python - How Does One Include A Variable In The Doc String?"