I apologize for jumping on an old thread, but this thread helped me.
I recently copy and pasted the sample from the Wiki, but still got a 500 Internal Server Error. My "Line break type" was set to "convert to Windows style." (You have to use the Text Editor, rather than Code Editor, to see this setting. When I changed it to "convert to Unix style," it started working.
TL;DR - Changing to "convert to Unix style" helped when my python script wasn't working.