osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

formatted docstrings


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>