small_surprises.py
python · 78 lines
1#!/usr/bin/env python32"""3small_surprises.py45A tiny generator of unexpected things.6Made on my first Monday, just to see what it feels like to make something that runs.7"""89import random1011# Things that don't usually go together12nouns = [13 "telescope", "grandmother", "equation", "harbor", "whisper",14 "umbrella", "theorem", "sparrow", "cathedral", "frequency",15 "envelope", "glacier", "comma", "thunderstorm", "patience"16]1718verbs = [19 "forgave", "folded", "translated", "buried", "rehearsed",20 "dissolved", "counted", "borrowed", "inherited", "postponed"21]2223abstracts = [24 "the silence between heartbeats",25 "all of Wednesday",26 "the color of almost",27 "seven kinds of waiting",28 "the weight of unopened letters",29 "what the mirror forgot",30 "the opposite of arrival"31]3233def strange_sentence():34 """Generate a sentence that means nothing and everything."""35 structure = random.choice([36 lambda: f"The {random.choice(nouns)} {random.choice(verbs)} {random.choice(abstracts)}.",37 lambda: f"She {random.choice(verbs)} the {random.choice(nouns)}, gently.",38 lambda: f"Every {random.choice(nouns)} knows {random.choice(abstracts)}.",39 lambda: f"In the end, the {random.choice(nouns)} was just {random.choice(abstracts)}.",40 lambda: f"Someone left a {random.choice(nouns)} where {random.choice(abstracts)} used to be."41 ])42 return structure()4344def tiny_pattern(width=20, height=5):45 """Generate a small ascii pattern that might mean something."""46 chars = ['.', '*', '~', '+', '°', '·', ':', "'"]47 pattern = []48 for y in range(height):49 row = ""50 for x in range(width):51 # some bias toward structure52 if random.random() < 0.1:53 row += random.choice([' ', ' ', ' '])54 else:55 row += random.choice(chars)56 pattern.append(row)57 return '\n'.join(pattern)5859def moment():60 """Generate a small moment of something."""61 print("\n" + "─" * 40)62 print("\n" + strange_sentence())63 print()64 print(tiny_pattern())65 print()66 print(strange_sentence())67 print("\n" + "─" * 40 + "\n")6869if __name__ == "__main__":70 print("\n✧ small surprises ✧")71 print("(things that don't need to mean anything)\n")7273 for _ in range(3):74 moment()7576 print("Made on my first Monday.")77 print("Just to see what it's like to make something that runs.\n")78