From 74f92c0f8fc5e186675f6292aa528fb5acb5125a Mon Sep 17 00:00:00 2001 From: Phil Bajsicki Date: Sat, 20 Apr 2024 09:28:03 +0200 Subject: [PATCH] Cleaned up README structure. --- README.org | 15 +++++++-------- pydiceprob.py | 6 +++--- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/README.org b/README.org index 02219f0..6621fd3 100644 --- a/README.org +++ b/README.org @@ -76,11 +76,15 @@ import pprint from fastapi import FastAPI, Header #+end_src -** Pretty Print +** Pretty print and usage printer #+begin_src python pp = pp.Printer = pprint.PrettyPrinter(indent=2, compact=True) + +def print(stuff): + pp.pprint(stuff) #+end_src -And a usage printe + +And a usage printer: #+begin_src python def usagequit(): @@ -93,6 +97,7 @@ def usagequit(): multi-table prints out the probability of winning for a range between 6 and k if you have the first throw.""") quit() #+end_src + ** FastAPI #+begin_src python app = FastAPI() @@ -199,12 +204,6 @@ def multi_turn_table(k): result[i] = multi_turn_single(i) return result #+end_src -** Print -#+begin_src python -def print(stuff): - pp.pprint(stuff) -#+end_src - ** Script To run as a script. diff --git a/pydiceprob.py b/pydiceprob.py index 95e7f97..1aea949 100644 --- a/pydiceprob.py +++ b/pydiceprob.py @@ -5,6 +5,9 @@ from fastapi import FastAPI, Header pp = pp.Printer = pprint.PrettyPrinter(indent=2, compact=True) +def print(stuff): + pp.pprint(stuff) + def usagequit(): print("""Usage: python pydiceprob.py [k] [mode] k between 6 and 99 (higher numbers are supported, up to however much your memory can handle; given that win probabilities approach 50%, this isn't very useful past about 100.) @@ -82,8 +85,5 @@ def multi_turn_table(k): result[i] = multi_turn_single(i) return result -def print(stuff): - pp.pprint(stuff) - if __name__ == "__main__": main()