Replace for Goto
Aahz
aahz at pythoncraft.com
Sun Jun 1 23:55:44 EDT 2003
In article <bbeamp$6db$1 at wheel2.two14.net>,
Martin Maney <maney at pobox.com> wrote:
>Aahz <aahz at pythoncraft.com> wrote:
>>
>> try:
>> for ORlist in includes:
>> try:
>> for filter in ORlist:
>> for field in curr_fields:
>> for item in record[field]:
>> if item.lower().find(filter) >= 0:
>> raise Found
>> else:
>> raise NotFound
>> except Found:
>> continue
>> except NotFound:
>> continue
>> else:
>> result.append(record)
>
>Speaking as one who has indented deeply when it felt appropriate, and
>actually used a triply-indirect pointer (not nested structures, just a
>few points where the code reached all the way to ***whatsit... and it
>did work and seemed perfectly reasonable at the time it was written)...
>
>That's scary. Or was it intended as the single example for a long
>afternoon demonstrating the effects of refactoring on code readability?
It was intended as a way of completely refactoring out flag variables.
I'd say that it's very, very dense, but not that hard to understand.
--
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
"If you don't know what your program is supposed to do, you'd better not
start writing it." --Dijkstra
More information about the Python-list
mailing list