[Tutor] "else:" triggering a Syntax Error

Stijn . stijnnederland at hotmail.com
Sat Feb 6 11:56:28 CET 2010


First of all I'd like to say that I'm new to python, and new to mailinglists. So if I make any mistakes, please correct me.

Now, onto my issue: I am trying to put an "else:" statement inside a class:

class Line(): #The class
    def __init__( self, start_dot, end_dot, width): #init function
        self.start_dot = start_dot
        self.surface = pygame.Surface((w, h), SRCALPHA)
        self.surface.fill((0,0,0,0))
        self.end_dot = end_dot
        self.width = width
        self.selected = 0
        self.tempX1 = start_dot.x
        self.tempY1 = start_dot.y
        self.tempX2 = end_dot.x
        self.tempY2 = end_dot.y
        self.visibleTemp1 = self.start_dot.visible
        self.visibleTemp2 = self.end_dot.visible
        self.draw = 0
        self.lastWasMove = 0
        self.Draw(1)
        self.rico = 0
    def Draw ( self, typeOf ): #draw function
         if ((self.start_dot.x > self.end_dot.x) and (self.start_dot.y != self.end_dot.y)):                  
              self.rico = (self.start_dot.x - self.end_dot.x / abs(self.start_dot.y - self.end_dot.y)
         else: #<-causes error message
              if ((self.start_dot.x < self.end_dot.x and self.start_dot.y != self.end_dot.y))
                   self.rico = (self.end_dot.x - self.start_dot.x) / abs(self.start_dot.y - self.end_dot.y)
              else:
                   self.rico = 0

the first "else" statement in the Draw() function triggers a syntax error. Could anyone please enlighten me why this is happening?

Thanks in advance!

Stijn
 		 	   		  
_________________________________________________________________
25GB gratis online harde schijf
http://skydrive.live.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100206/25a8d261/attachment.htm>


More information about the Tutor mailing list