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

  • Home
  • SEARCH
  • 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 8049951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:55:47+00:00 2026-06-05T06:55:47+00:00

I am preparing an api, and using docstrings as documentation. An api service selects

  • 0

I am preparing an api, and using docstrings as documentation. An api service selects the related ApiClass methods and join each docstring to create the documentation. This way, both program developers and users of the api reached the same documentation.

My class structure is like:

API_STATUS = {
    1: 'some status',
    2: 'some other status message'
}

class MyApi:
    def __init__(self):
        blah blah blah

    def ApiService1(self, some_param):
        """ 
        here is the documentation
            * some thing
            * some other thing
        keep on explanation
        """
        do some job 

    def  ApiService2(self, some_param):
        """"
        Another doc...
        """
        do some other job

I am using HttpResponse to return the final documentation string. So when i request service documentation, output is quite readable

ApiService1

    here is the documentation
        * some thing
        * some other thing
    keep on explanation

ApiService2

    Another doc...

All is great up to here, but there is some variables like API_STATUS dictionary ans some lists, which i wish to add them to the documentation. But when i parse them to string, or call repr function, all formatting is gone

{1: ‘some status’ 2: ‘some other status message’, 3: ‘…..’, 4: ‘……..’, ….}

which makes it unreadable (since dict has about 50 elements.).

I do not want to write is down as a docstring (because in future updates, related dict may be updated and dicstring might be forgotten)

Is there a way to add my dictionary to my responsing documentation string (before returning it as HttpResponse) without removing sytling indents?

  • 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-06-05T06:55:48+00:00Added an answer on June 5, 2026 at 6:55 am

    Use pprint:

    >>> API_STATUS = {1: 'some status', 2: 'some other status message'}
    >>> import pprint
    >>> pprint.pprint(API_STATUS, width=1)
    {1: 'some status',
     2: 'some other status message'}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im preparing API methods for one of the system. Api will be available for
I am preparing for my interview and came across this question: Consider that i
i am preparing my android apps in which i want to create two row
Where can I find centralized and complete documentation aboput Linux - specific API? I'm
Preparing for exam and got stuck at this question: Allowed operators are <<,+,& no
I'm preparing a set of reports using open source ReportLab. The reports contain a
I am preparing a script. I am using AJAX(load()) with jQuery. I am getting
I am preparing for my interview tomorrow -- I need the answer to this
I am preparing a registration page using JSF/Spring webflow&mvc application. I have added two
I have put together a HTTP driven API using the WCF WebAPI that uses

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.