Python Forum
get docstring to work with another block of text at the top
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
get docstring to work with another block of text at the top
#5
i'm going to do this. everything will be in the docstring. it will start with just one to a few lines describing basically what the script is for. fewer lines is better. just one line will be typical. each part that follows will be led by a blank line, then a line with the name of that part appended with ":", then a blank line. the license part will be first. i will include a function to get the requested part from the docstring.

i'm wondering if i can assign to __docstring__. if i can then maybe i can use a f-string (not allowed on regular docstring).

wow, we were typing in the same time, you slightly ahead of me.

this example for POSIX systems:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""This script says hello to the world.

license:

This script is in the public domain.

info:

script          helloworld
file            helloworld.py
author          Phil Howard
email           11054987560151472272755686915985840251291393453694611309
hint            provu igi la numeron al duuma

help:

Run this script to see it say "Hello World".  Make a copy of file helloworld.py to another file name you prefer and use your favorite text editor to change it to be your first Python script.
"""
print("Hello World")
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Messages In This Thread
RE: get docstring to work with another block of text at the top - by Skaperen - Dec-28-2019, 10:37 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  a longer docstring Skaperen 8 1,709 Aug-25-2022, 11:21 PM
Last Post: Skaperen
  How to write in text file - indented block Joni_Engr 4 6,499 Jul-18-2022, 09:09 AM
Last Post: Hathemand
  Getting a GET request output text into a variable to work with it. LeoT 2 3,075 Feb-24-2021, 02:05 PM
Last Post: LeoT
  calling a method for a docstring Skaperen 8 3,048 Jan-27-2020, 01:16 AM
Last Post: Skaperen
  capture next block of text after finding error in file kdefilip2 6 3,486 Nov-27-2019, 07:36 PM
Last Post: buran
  How work with formatted text in Python? AlekseyPython 3 2,843 Mar-18-2019, 05:00 AM
Last Post: AlekseyPython
  Strip does not work when applied on a string read from a text file. susmis666 1 2,408 Dec-27-2018, 07:07 AM
Last Post: perfringo
  ptpython docstring metulburr 4 4,504 Nov-17-2017, 01:36 AM
Last Post: metulburr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020