Posts: 4,647
Threads: 1,494
Joined: Sep 2016
i want to assign the text of the license for my script to a variable. and i want this to be the first block of text one sees when slowly reading the file. but if i put this assignment first, then the docstring will not be set up. is there a way around this conflict?
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,647
Threads: 1,494
Joined: Sep 2016
i'm wanting to put the help text in the docstring and have the script output that if help is requested. but i don't want it to output the license unless requested.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,647
Threads: 1,494
Joined: Sep 2016
Dec-28-2019, 10:37 PM
(This post was last modified: Dec-28-2019, 10:53 PM by Skaperen.)
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.