Style suggestions/critiques

Michael F. Stemper michael.stemper at gmail.com
Tue Aug 20 17:11:54 EDT 2019


I recently wrote a couple of modules (more to come) to help me
use the tikz package in TeX/LaTeX. Since it's all to do with
drawing, I have a lot of points in R^2. Being unimaginative, I
implemented them as ordered pairs (2-tuples) of floats. E.g.:

p1 = 3,4
p2 = 5,6

Naturally, lines are implemented as ordered pairs[1] of points:

line = p1,p2

This all seems reasonably simple and intuitive (to me). However,
in order to actually do some manipulation, I have stuff like:

# Unpack the lines
l1p1,l1p2 = line1
l1x1,l1y1 = l1p1
l1x2,l1y2 = l1p2
l2p1,l2p2 = line2
l2x1,l2y1 = l2p1
l2x2,l2y2 = l2p2

spattered all over. Although this is simple enough, I find it
aesthetically unappealing.

Is there some better idiom that I should be using, or is this
really in accord with The Zen of Python?

[1] (I could have done sets, I suppose, but orientation might be
useful at some point.)

-- 
Michael F. Stemper
The FAQ for rec.arts.sf.written is at:
http://leepers.us/evelyn/faqs/sf-written
Please read it before posting.



More information about the Python-list mailing list