Given all that beautiful documentation at nrn.readthedocs.io I find it even more surprising that it is so difficult to discover the answer to your question. One would expect it to be with the other documentation about Section, but it isn't. But wait, there's a Search feature . . . which isn't very helpful for this particular problem.
what my current solution relies on
is clever but horrible.
The answer should be, but isn't, in the Index. However it is implicit in the
Scripting NEURON basics text under the heading
Aside 6: Accessing segment variables (aside 6?? who would have guessed???), which you will find here
https://nrn.readthedocs.io/en/latest/tu ... -variables--until somebody redoes the documentation [again] and, not recognizing the importance of this bit, tosses it down the memory hole.
"What", you may well ask, "am I supposed to glean from this?"
If foo refers to a segment in some section bah, then foo.x returns the range of the node at the center of foo (i.e. normalized distance of that node from bah's 0 end). Example:
dend = h.Section('dend')
dend.nseg = 5
print(dend(0.5).x) # will print 0.5
for seg in dend: print(seg.x) # will print 0.1 0.3 0.5 0.7 0.9
If you want to include the nodes at 0 and 1, the syntax is
for seg in dend.allseg(): print(seg.x) # will print 0.0 0.1 0.3 0.5 0.7 0.9 1.0