Uncaught ReferenceError: rotateAnimation is not defined(anonymous function)
<p>please have patience for me, I am new at programming :)
I am testing Brython in browsers. I have this code for simple rotate image, in this case it's a cog.
I wan to use python and DOM to animate this image of cog.
This is the code:</p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;

&lt;!-- load Brython --&gt;
&lt;script src="http://brython.info/src/brython_dist.js"&gt;&lt;/script&gt;


&lt;!-- the main script; after loading, Brython will run all 'text/python3' scripts --&gt;
&lt;script type='text/python3'&gt;
from browser import window, timer, document, html

def user_agent():
    """ Helper function for determining the user agent """
   if window.navigator.userAgent.find('Chrome'):
       return 'chrome'
   elif window.navigator.userAgent.find('Firefox'):
       return 'firefox'
   elif window.navigator.userAgent.find('MSIE'):
       return 'msie'
   elif window.navigator.userAgent.find('Opera'):
       return 'opera'

# Dict Mapping UserAgents to Transform Property names
rotate_property = {
   'chrome':'WebkitTransform',
   'firefox':'MozTransform',
   'msie':'msTransform',
   'opera':'OTransform'
}

degrees = 0
def animation_step(elem_id):
   """ Called every 30msec to increase the rotatation of the element. """
   global degrees, tm

   # Get the right property name according to the useragent
   agent = user_agent()
   prop = rotate_property.get(agent,'transform')

   # Get the element by id
   el = document[elem_id]

   # Set the rotation of the element
   setattr(el.style, prop, "rotate("+str(degrees)+"deg)")
   document['status'].innerHTML = "rotate("+str(degrees)+"deg)"

   # Increase the rotation
   degrees += 1
   if degrees &gt; 359:
       # Stops the animation after 360 steps
       timer.clear_interval(tm)
       degrees = 0

# Start the animation
tm = timer.set_interval(lambda id='img1':animation_step(id),30)
&lt;/script&gt;

&lt;/head&gt;

&lt;!-- After the page has finished loading, run bootstrap Brython by running
     the Brython function. The argument '1' tells Brython to print error
     messages to the console. --&gt;
&lt;body onload='brython(1)'&gt;

&lt;img id="img1" src="cog1.png" alt="cog1"&gt;
&lt;script&gt;rotateAnimation("img1",30);&lt;/script&gt;
&lt;h2 style="width:200px;" id="status"&gt;&lt;/h2&gt;
&lt;/body&gt;  
&lt;/html&gt;
</code></pre>

<p>This is source code in JavaScript:</p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;script&gt;
var looper;
var degrees = 0;
function rotateAnimation(el,speed){
    var elem = document.getElementById(el);
    if(navigator.userAgent.match("Chrome")){
        elem.style.WebkitTransform = "rotate("+degrees+"deg)";
    } else if(navigator.userAgent.match("Firefox")){
        elem.style.MozTransform = "rotate("+degrees+"deg)";
    } else if(navigator.userAgent.match("MSIE")){
        elem.style.msTransform = "rotate("+degrees+"deg)";
    } else if(navigator.userAgent.match("Opera")){
        elem.style.OTransform = "rotate("+degrees+"deg)";
    } else {
        elem.style.transform = "rotate("+degrees+"deg)";
    }
    looper = setTimeout('rotateAnimation(\''+el+'\','+speed+')',speed);
    degrees++;
    if(degrees &gt; 359){
        degrees = 1;
    }
    document.getElementById("status").innerHTML = "rotate("+degrees+"deg)";
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;img id="img1" src="cog1.png" alt="cog1"&gt;
&lt;script&gt;rotateAnimation("img1",30);&lt;/script&gt;
&lt;h2 style="width:200px;" id="status"&gt;&lt;/h2&gt;
&lt;/body&gt;  
&lt;/html&gt;
</code></pre>

<p>I have error:</p>

<pre><code>(index):67 Uncaught ReferenceError: rotateAnimation is not defined(anonymous 

function) @ (index):67
brython_dist.js:4985 File "__main__", line 6
    if window.navigator.userAgent.find('Chrome'):
IndentationError: unexpected indent
</code></pre>

<p>What's wrong?</p>

<p>If I change</p>

<pre><code>&lt;script&gt;rotateAnimation("img1",30);&lt;/script&gt;
</code></pre>

<p>to</p>

<pre><code>&lt;script&gt;animation_step("img1",30);&lt;/script&gt;
</code></pre>

<p>I have error:</p>

<pre><code>(index):67 Uncaught ReferenceError: animation_step is not defined(anonymous function) @ (index):67
brython_dist.js:4985 File "__main__", line 6
    if window.navigator.userAgent.find('Chrome'):
IndentationError: unexpected indent
</code></pre>

<p>in line 14</p>

<pre><code>    """ Helper function for determining the user agent """
</code></pre>

<p>to much space's</p>

<p>Should be</p>

<pre><code>   """ Helper function for determining the user agent """
</code></pre>

javascript python html dom brython