How to stop Action Constraint giving different results when code is run in text editor vs python console?
You change the frame number twice in your script:

bpy.context.scene.frame_current = NUMBER


The frame_current property  should be used for reading the current frame number only, or some special cases in which you don't want to fully update the scene to this frame.

Use the method frame_set(...) instead. It forces an immediate update of all objects in the scene, including animations (transformation matrices etc. will be calculated)

Scripts run from the Text Editor or as addons behave slightly different compared to the Python Console. There are implicit updates when using the PyConsole, which may give the impression of a function causing an update itself. But once you try it in the Text Editor or as addon, you'll experience behavior like you described (basically missing instant updates during an operation, 'cause it's not done automatically).

By the way: although Python supports ; as punctuator, it is no good style.