Python syntax errors
<p>I am having a few problems with my code.. I am following an example in the book "Beginning Game Development with Python and Pygame" (example 2-4 and 2-5) and I am getting syntax errors. Below is the code in question. I am new to Python and probably just did a typo.</p>

<p>The book uses python 2.4. I'm getting the error for 2.7 and 3.2.</p>

<p>Two problems:</p>

<p>the code line with:</p>

<pre><code>my_tank = Tank("Bob")
</code></pre>

<p>is receiving a syntax error. <code>my_tank</code> is highlighted. I did get it to start working but I am not sure why it started to.</p>

<p>The code line with:</p>

<pre><code>print self.name, "fires on", enemy.name
</code></pre>

<p>is also recieveing a syntax error. The <code>self</code> in this line is highlighted. When <code>my_tank</code> stared working I started to receive this error. Not sure whats going on here.</p>

<pre><code>class Tank(object):

    def _init_(self, name):
        self.name = name
        self.alive = True
        self.ammo = 5
        self.armor = 60

    my_tank = Tank("Bob")

    def _str_(self):

        if self.alive:
            return "%s (%i armor, %i shells)" % (self.name, self.armor, self.ammo)
        else:
            return "%s (dead)" % self.name

    def fire_at(self, enemy):

        if self.ammo &gt;= 1:
            self.ammo -= 1
            print self.name, "fires on", enemy.name
            enem.hit()
        else:
            print self.name, "has no shells!"

    def hit(self):

        self.armor -= 20
        print self.name, "is hit!"
        if self.armor &lt;= 0:
            self.explode()

    def explode(self):

        self.alive = False
        print self.name, "explodes!"
</code></pre>
