Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7660499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:28:27+00:00 2026-05-31T13:28:27+00:00

A python docstring must be given as a literal string; but sometimes it’s useful

  • 0

A python docstring must be given as a literal string; but sometimes it’s useful to have similar docstrings for several functions (e.g., different constructors), or several access methods might accept the same list of arguments (and then rely on the same hidden method), so it would be nice to use the same description everywhere. For such cases I can construct a docstring by assigning to __doc__, which I do by means of a simple decorator. The system works very nicely (in python 2), and I’m pleased with how simple, clear and well-encapsulated it is.

The question: Is this a good idea? In particular, are there tools that would be confused by this set-up (e.g., anything that extracts docstrings from the source rather than from the bytecode). Is the solution still going to work in python 3? Are there other reasons or circumstances that would make this inadvisable?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T13:28:28+00:00Added an answer on May 31, 2026 at 1:28 pm

    It should not break any tools and it should work on Python 3.

    It is ok If it doesn’t hurt a source code readability i.e., you can still find out what the function does and how to use it.

    The problem might be that it masks a poor design. If several methods use the same list of arguments the code should be refactored (create an object that works with the list) rather than patched by generating repetitive docstrings.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Python you can have a multiline string like this using a docstring foo
Not many are aware of this feature, but Python's functions (and methods) can have
Well, I love Python, but find mainly two things annoying: self and docstrings below
Python has re.escape() if you want to match an arbitrary string literal. In my
I have a Python script with a docstring. When the parsing of the command-line
Love TextMate, love Python, blah, blah, blah .. But.. i hate that Docstrings, aka
I'd like to run a spell checker on the docstrings of my Python code,
Python's getattr() method is useful when you don't know the name of a certain
Python is doing string multiplication where I would expect it to do numeric multiplication,
I have a conceptual Python design dilemma. Say I have a City class, which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.