Question on using FP numbers in python 2

Gene Heskett gheskett at
Sat Feb 15 06:50:51 CET 2014

On Saturday 15 February 2014 00:43:53 Chris Angelico did opine:

> On Sat, Feb 15, 2014 at 4:07 PM, Gene Heskett <gheskett at> wrote:
> > Not extract, but let you get & look at the code, its the top entry on
> > this page:
> > 
> > <
> > Code_Generators#Counterbore_Software>
> Interesting. At the top of the file, it says GPL3 or later; but then
> it puts a requirement on making money off the software. I'm not sure
> that's a good thing (what if someone lifts a small part of that code
> out and into another GPL project?), and I'm not sure it's
> legal/enforceable anyway.
> The GUI creation code calls to mind the discussion we had a little
> while ago about an alternative way to create a GUI in Python.
> Especially compare the GTK2Table() function that I posited - I'm sure
> it wouldn't be hard to make a Python (and Tkinter) equivalent.
> Massively complicated code for laying out a grid/table.
> But check out these comments:
>     def GeneratePath(self):
>          # If ToolDiameter > HoleDiameter then Complain
>          # If ToolDiameter == HoleDiameter then Plunge to HoleDepth
>          # If (ToolDiameter*1.25) <= HoleDiameter then Plunge to each
> Level and Spiral out to HoleDiameter
>         # If (ToolDiameter*1.25) > HoleDiameter then Spiral to each
> Level and Spiral out to HoleDiameter
> (Also, owwww! The GeneratePath function is indented with a mixture of
> spaces and tabs. Most of it is indented "four spaces and then a tab",
> but some lines use other mixtures. Ow ow ow!)
> Does all that make sense, and are you seeing those boundaries
> correctly? I strongly suspect you're not seeing a floating-point
> error, but a deliberate piece of code and maybe some other form of
> bug. I very much doubt the boundary is anything to do with going over
> 1" in diameter; the numbers you're working with here are easily within
> Python's capability (you get roughly 15 decimal digits of accuracy
> with the default float type).
> I'm afraid I can't really help more, as I don't speak CNC.

Actually, the output is RS-274-D, originally from NIST.  But it has 
developed some pretty distinct "accents" in the 20 some years its been in 
the wild.  The NIST version was, shall we say, quite incomplete but a lot 
of the stuff shoved in to scratch this or that itch is often vaguely 
incompatible with the next vendors version of that particular function.

> But have a
> look at GeneratePath(); it does have comments, and for all of being
> two hundred lines of code, it's reasonably segmented into sections.
> Manually step through it, see where it's going wrong. Standard Python
> debugging, nothing to do with floats AFAICT.
> ChrisA

I'll do that when next I have both eyes open at the same time. That is 
usually about halfway thru the third cuppa. :)

Thanks Chris A.

Cheers, Gene
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Genes Web page <>

NOTICE: Will pay 100 USD for an HP-4815A defective but
complete probe assembly.

More information about the Python-list mailing list