I see in some other people's Python code that they paste some checks before the docstring of the function; something like this:
def func(args):
if x_version != 1.7:
return
"""docstring is here"""
# function body code
# ...
Are there any cases when you should or have to put some code before the docstring to workaround anything? Are there any special cases that this style had to be introduced or it's always just a bad styling and thus must be fixed to something like this?
def func(args):
"""docstring is here"""
if x_version != 1.7:
return
# function body code
# ...
inspect
module to see if there were functions with no docstrings and that's how I found the function with the moved docstring :) so you can't think of any special case when you have to put any Python code before the docstring (understanding that the docstring will not be available for others in IDEs etc)? – Nettles