On Wed, 15 Dec 2004 19:58:56 -0500, Brian van den Broek <[EMAIL PROTECTED]> wrote: > As I mentioned, I feel as though I have a mental block getting in the > way of coming up with code in the smoother fashion of the second snippet > above. As I have been making a lot of use of a construct (pattern?) > similar to my code above, wherein I try something, and return True if it > works, False if it doesn't, I've begun to wonder if I am overlooking a > improvement similar to that in DogWalker's suggestion. As an example of > the sort of thing I have been doing:
This reply might seem embarassingly short compared to the other answers you got. But I would like to point out two things that could be worth thinking about and that could help you "tune in" to a more direct line of thinking. 1) Every operation has a return value [unless purposefully left out] This includes, but is not limited to; mathematical operations (of course), variable assignment, compare blocks, etc.. 2) If you collect the value first, and then use the collect-variable for checking things, chances are you might be able to exclude the collect-variable completely. This also applies to "state flag"-variables (like in_range in your own solution suggestion). Might not be much worth, but it's my two cents. ;) -L.C _______________________________________________ Tutor maillist - [EMAIL PROTECTED] http://mail.python.org/mailman/listinfo/tutor