Установка строки документации для выражения внутри def
Я хотел бы установитьfunc_doc
(как выражение)within def
.
def f():
'''My function help''' #Set the docstring
def g():
"My function " + "help" # An expression, so not read as a docstring
# can I put something here to set the docstring as an expression?
g.func_doc # is None
g.func_doc = "My function " + "help" # This works
Это возможно?
(two reasons I can think for doing this: importing a function from a module (and you want to import the docstring too) and using a лексический.)