How to dynamically set Current_ Frame in Driver Namespace Function Call? The driver namespace function call(wiggle_z) gives a float error even when float values are provided for the framerange in the driver scripted expression field .
How to resolve this ?
TEST  CALL
wiggle_z(50.0,200.0)

ERROR:
Error in Driver: The following Python expression failed:
    'wiggle_z(50.0,200.0)'
TypeError: a float is required

SCRIPT:
import bpy
ob  = bpy.context.object 
scene = bpy.context.scene
frame_current = bpy.app.driver_namespace[&quot;frame&quot;]

import math   

def wiggle_z(frame_start,frame_end):

    if frame_current &gt; frame_start and frame_current &lt; frame_end:
        ob.rotation_euler[2] = math.sin(frame_current)/ 10

    else:
        ob.rotation_euler[2] = 0 



bpy.app.driver_namespace[&quot;wiggle_z&quot;] = wiggle_z #wiggles object around Z axis within frame_range


#def main():             
#    wiggle_z(50.0,200.0) #Test Call
#main()
Return the value from a driver, don't set it.
So many things wrong with such a little script.
In addition to comments below question:
Don't mix context and drivers, the driver returns a value to the property it is driving.  To drive the z rotation of an object with wiggle, simply type directly into field.  Using hash as first character when first entering informs blender to treat input as  a driver expression #wiggle(1, 35)
Here it is seen as purple (a driver) after being added as above

The frame is known to the driver namespace as &quot;frame&quot;, have used that rather than passing frame via arguments or setting up a variable using scene.
import bpy
from bpy.app import driver_namespace as dns
from math import sin

def wiggle(frame_start, frame_end):
    frame = dns[&quot;frame&quot;] # saves passing it
    if frame_start &lt;= frame &lt;= frame_end:
        return sin(frame) / 10
    return 0.0

dns[&quot;wiggle&quot;] = wiggle