for what are for/while else clauses
Michele Simionato
michele.simionato at poste.it
Fri Nov 28 01:31:46 EST 2003
More information about the Python-list mailing list
Fri Nov 28 01:31:46 EST 2003
- Previous message (by thread): for what are for/while else clauses
- Next message (by thread): for what are for/while else clauses
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
magnus at thinkware.se (Magnus Lyck?) wrote in message news:<258fd9b8.0311271519.153f573d at posting.google.com>... > First of all, I'm not sure it's a good idea to use > exceptions like a poor (rich?) man's GOTO like this. :) > > If you persist, I'm not so sure your code is clearer than: > > try: > for ORlist in includes: > try: > for filter in ORlist: > for field in curr_fields: > for item in record[field]: > if match(item, filter): > raise Found > raise NotFound > except Found: > continue > except NotFound: > continue > else: > result.append(record) > > With the else clause on the for loop, just after the if > statement, you are bound to confuse people. I would guess > that most people who casually looked at that code would > think that you had made an indentation mistake. Some would > probably "correct" it. I, for one, could get confused. BTW, I don't remember a single case in all my code where I have used so much indentation. I would write some helper function and avoid nesting as much as possible. Michelee
- Previous message (by thread): for what are for/while else clauses
- Next message (by thread): for what are for/while else clauses
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list