How do you convert an expression that works in the console into a format a driver can make use of? I'm trying to convert the following expression for use in a driver expression:

1 if ( bpy.context.scene.frame_current == bpy.context.scene.frame_end ) else 0


So there's the "Give a man a fish" answer that expresses how to tell you're on the final frame of a render, and then there's the "Teach a man to fish" answer that more generally helps myself and everyone who follows learn how to make drivers work. But at this point I'll take whatever assistance a kind soul cares to render!
You can use a single line python expression as a driver, like an if-else statement.

1 if (bpy.context.scene.frame_current  == 1) else 0


The reason this fails, would be if python scripts have been disabled. You get this dialog after entering a python expression when python scripts are disabled. Click on "Allow Execution".



If you dismissed the dialog, enable Auto Run Python Scripts in the User Preferences under Save &amp; Load.