Python - if/else statements

John Roth newsgroups at jhrothjr.com
Sat Jul 12 13:06:33 CEST 2003


Is there anything consistent about either the version of
Python these people are using, or the version of KDE?
The reason I ask is that there are a lot of different
versions out there, and while the Python maintainers
are very good, some of them have subtle bugs. Likewise
for KDE, and for various distributions.

I also second Bengt's comment about tabs. Outlook
Express, for one, eliminates them so your code example
is simply unreadable. The python standard coding style
is to use 4 spaces for each level of indentation. Python
aware editors supply them automatically when you hit
the tab key.

John Roth

"dmbkiwi" <dmbkiwi at yahoo.com> wrote in message
news:pan.2003.07.11.19.34.16.330762 at yahoo.com...
> 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