The hardest problem in computer science...

Steve D'Aprano steve+python at pearwood.info
Fri Jan 6 08:03:37 EST 2017


The second hardest problem in computer science is cache invalidation.

The *hardest* problem is naming things.

In a hierarchical tree view widget that displays items like this:


    Fiction
    ├─ Fantasy
    │  ├─ Terry Pratchett
    │  │  ├─ Discworld
    │  │  │  ├─ Wyrd Sisters
    │  │  │  └─ Carpe Jugulum
    │  │  └─ Dodger
    │  └─ JK Rowling
    │     └─ Harry Potter And The Philosopher's Stone
    ├─ Science Fiction
    │  ├─ Connie Willis
    │  │  └─ To Say Nothing Of The Dog
    │  └─ Neal Stephenson
    │     └─ Snow Crash
    └─ Horror
       └─ Stephen King
          ├─ Salem's Lot
          └─ It


what do we call the vertical and horizontal line elements? I want to make
them configurable, which means the user has to be able to pass an argument
that specifies them. I have names for the individual components:

XXX = namedtuple("XXX", "vline tee corner")

default_YYY = XXX("│  ", "├─ ", "└─ ")
bold_YYY = XXX("┃  ", "┣━ ", "┗━ ")
ascii_YYY = XXX("|  ", "|- ", "+- ")

def draw_tree(tree, YYY=default_YYY):
    ...


but what do I call XXX and YYY?


Seriously-considering-just-hard-coding-them-as-magic-constants-ly y'rs,


-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.



More information about the Python-list mailing list