Python - if/else statements

dmbkiwi dmbkiwi at yahoo.com
Fri Jul 11 15:34:18 EDT 2003


I am new to this group, and relatively new to python programming, however,
have encountered a problem I just cannot solve through reading the
documentation, and searching this group on google.

I have written a theme in python for the superkaramba theme engine on kde
(see http://netdragon.sourceforge.net - if you are a kde/linux user, it is
a great visual applet engine).  I have uploaded it to www.kdelook.org for
others to download and use, however, some users are having an issue, which
to me seems to be very strange.

Basically the problem is that their version of python is ignoring an
if/else statement, and I can't understand why.  Over 3000 people have
downloaded the theme, and only 3 people have identified this problem.  The
relevant portion of code is:

def meterClicked(widget, meter, button):
	#print "meterclick"
	global dayshow, daypicrem, ddon, ddcon, buttonpressed
	if (meter == mainpic) and (button == 1):
		if ddcon == 0:
			if ddon == 1:
				deleteDayDetail(widget, dayshow)
				karamba.redrawWidget(widget)
			createCurrentDetail(widget)
			karamba.redrawWidget(widget)
		else:
			deleteCurrentDetail(widget)
	else:
		for i in range(0,5):
			if (meter == daypicrem[i]) and (button == 1) and (dayshow != i):
				#print "buttonpressed: day" + str(i)
				if ddon == 1:
					deleteDayDetail(widget, dayshow)
					karamba.redrawWidget(widget)
				elif ddcon == 1:
					deleteCurrentDetail(widget)
					karamba.redrawWidget(widget)
				createDayDetail(widget, i)
				karamba.redrawWidget(widget)
				dayshow = i
				#print dayshow
				break
			if (meter == daypicrem[i]) and (button == 1) and (dayshow == i):
				if ddon == 1:
					deleteDayDetail(widget, dayshow)
					karamba.redrawWidget(widget)
				elif ddcon == 1:
					deleteCurrentDetail(widget)
					karamba.redrawWidget(widget)
				dayshow = i
				#print dayshow
				break
	buttonpressed = 1


What these users are experiencing is that this portion of code is being
processed, and evaluating all if statements as true, however, as you can
see, they cannot all be true each time this function is called.  Their
versions of python also ignore the else construct.

Can anyone shed any light on what might be going on with these users?

Matt  




More information about the Python-list mailing list