Re: a more precise distance algorithm

2015-05-25 Thread ravas
On Monday, May 25, 2015 at 10:16:02 PM UTC-7, Gary Herron wrote: > It's probably not the square root that's causing the inaccuracies. In > many other cases, and probably here also, it's the summing of two > numbers that have vastly different values that loses precision. A > demonstration: > >

Re: a more precise distance algorithm

2015-05-25 Thread ravas
Oh ya... true >_< Thanks :D On Monday, May 25, 2015 at 9:43:47 PM UTC-7, Ian wrote: > > def distance(A, B): > > """ > > A & B are objects with x and y attributes > > :return: the distance between A and B > > """ > > dx = B.x - A.x > > dy = B.y - A.y > > a = min(dx, dy)

Re: a more precise distance algorithm

2015-05-25 Thread ravas
On Monday, May 25, 2015 at 8:11:25 PM UTC-7, Steven D'Aprano wrote: > Let's compare three methods. > ... > which shows that: > > (1) It's not hard to find mismatches; > (2) It's not obvious which of the three methods is more accurate. Thank you; that is very helpful! I'm curious: what about the

Re: a more precise distance algorithm

2015-05-25 Thread ravas
On Monday, May 25, 2015 at 1:27:43 PM UTC-7, Gary Herron wrote: > This is a statement about floating point numeric calculations on a > computer,. As such, it does apply to Python which uses the underlying > hardware for floating point calculations. > > Validity is another matter. Where did yo

Re: a more precise distance algorithm

2015-05-25 Thread ravas
On Monday, May 25, 2015 at 1:27:24 PM UTC-7, Christian Gollwitzer wrote: > Wrong. Just use the built-in function Math.hypot() - it should handle > these cases and also overflow, infinity etc. in the best possible way. > > Apfelkiste:~ chris$ python > Python 2.7.2 (default, Oct 11 2012, 20:14:37)

a more precise distance algorithm

2015-05-25 Thread ravas
I read an interesting comment: """ The coolest thing I've ever discovered about Pythagorean's Theorem is an alternate way to calculate it. If you write a program that uses the distance form c = sqrt(a^2 + b^2) you will suffer from the lose of half of your available precision because the square r

Re: find all multiplicands and multipliers for a number

2015-04-11 Thread ravas
Thank you all. I learned a lot. -- https://mail.python.org/mailman/listinfo/python-list

find all multiplicands and multipliers for a number

2015-04-10 Thread ravas
def m_and_m(dividend): rlist = [] dm = divmod end = (dividend // 2) + 1 for divisor in range(1, end): q, r = dm(dividend, divisor) if r is 0: rlist.append((divisor, q)) return rlist print(m_and_m(999)) --- output: [(1, 999), (3, 333), (9, 111), (27,

Re: apostrophe not considered with tkinter's wordstart and wordend

2015-01-24 Thread ravas
I copied the GUI creation from my personal text editor. The scrollbar and stretchability could have been left out, for sure. You're only seeing a portion of a more complex GUI. After writing several Tkinter applications, I decided that subclassing without a clear reason only had the effect of

Re: apostrophe not considered with tkinter's wordstart and wordend

2015-01-24 Thread ravas
We resolved it over at the comp.lang.tcl group. It turns out what Christian suggested affects what is selected when you double click a word. He later discovered a different method for producing what I want. Below is my test code that implements both of these things (tested with Python 3.4 and PyCh

Re: apostrophe not considered with tkinter's wordstart and wordend

2015-01-05 Thread ravas
Thanks guys :-] Rick Johnson: > but you could implement any pattern matching you want > by binding the correct events and then processing the > "target string" on the Python side. I'm curious about what events you would use. The only work around I thought of is to create a word list and then app

apostrophe not considered with tkinter's wordstart and wordend

2015-01-03 Thread ravas
When I place my mouse over a word (and I press something) I want the program to analyze the word. Tkinter almost provides the perfect option: self.text.get('current wordstart', 'current wordend') Unfortunately apostrophes are not considered using wordstart and wordend. http://infohost.nmt.edu/tcc