How can a blender driver python script access scene properties like FPS? I would like to be able to access properties of the current scene such as render.fps, frame_start, and frame_end from within a python driver script.  I have some data that is defined in terms of seconds, and I'd like the drivers consuming that data to work in two different scenes which have different frame rates.

edit: I tried using bpy.context.scene, but it turns out that is often wrong.  Let me be specific:  The driver is being evaluated to calculate the position of an object in scene "cave" and bpy.context.scene refers to scene "splash" .  In a 1-scene .blend bpy.context.scene works fine.  In a multi-scene .blend, bpy.context is not necessarily populated with what a reasonable person would consider 'the context of the driver'.
Inside script editor define your own function and register it for driver use:

import bpy

def driver_fce():
    scn = bpy.context.scene
    # You can use here:
    scn.frame_current
    scn.frame_start
    scn.frame_end
    scn.render.fps
    # etc..

    return 0    # some value

# Register it to driver namespace under name 'driver_fce':
bpy.app.driver_namespace['driver_fce'] = driver_fce


Use it like this:



Note that such drivers on node properties do not update correctly and its better to use frame change callback handler instead in that case.