formatted docstrings

Cameron Simpson cs at cskk.id.au
Wed Apr 3 23:05:17 EDT 2019


I just wrote this (specifics changed for confidentiality reasons):

  DEFAULT_ENVVAR = 'APP_VALUE'

  def get_handle(setting=None):
    f'''Get a handle.

        Parameter:
        * `setting`: the application setting.
          Default from the {DEFAULT_ENVVAR} environment variable.
    '''
    if setting is None:
      setting = os.environ[DEFAULT_ENVVAR]

I thought this was way cool. Until I disovered that there was no 
docstring because a format string is not a string literal.

Is it unreasonable to promote bare format strings as candidates for the 
docstring?

Cheers,
Cameron Simpson <cs at cskk.id.au>



More information about the Python-list mailing list