best way to increment an IntVar?

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Fri Jun 25 22:28:15 EDT 2010


On Fri, 25 Jun 2010 17:00:37 -0700, rantingrick wrote:

> Looks like the dev cycle is completely "idle" at this point and
> suffering the fate of monkey patch syndrome.

That's the second time that I've noticed you use the term "monkey patch". 
I don't think it means what you seem to think it means. You seem to be 
using it in the sense of "being patched by monkeys", but that's not the 
commonly agreed meaning of monkey-patching.

Monkey-patching is patching code on the fly, rather than modifying the 
source code or subclassing it. For example, suppose for I wanted math.sin 
to accept arguments in degrees rather than radians, I might do this:

import math
_sin = math.sin  # save the original code
def sin(x):
    return _sin(math.radians(x))

math.sin = sin


And lo and behold, now every module that uses math.sin will see your new 
version. That's a monkey-patch. It's an incredibly powerful technique, 
allowing you to not only shoot your own foot off, but that of everyone 
else as well.

http://en.wikipedia.org/wiki/Monkey_patch



-- 
Steven



More information about the Python-list mailing list