A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2001-April/077124.html below:

How best to write this if-else?

How best to write this if-else? How best to write this if-else?Ingo Wilken Ingo.Wilken at Informatik.Uni-Oldenburg.DE
Sat Apr 21 16:49:55 EDT 2001
Roy Smith <roy at panix.com> writes:
>e1 = re.compile ('...')
>e2 = re.compile ('...')
>e3 = re.compile ('...')
>line = file.readline()

for e in [e1, e2, e3]:
    m = e.match(line)
    if m:
        text = m.group(1)
        break
else:
    no match found

Note that the 'else' belongs to the 'for', not to the 'if'.

Regards,
Ingo
-- 
"I like VIM because, when I ask a question in this NG, I get a one-line
 answer. With xemacs, I get a 1Kb lisp script with bugs in it ;-)"
    -- wroot at my-deja.com in comp.editors, <948toi$ttt$1 at nnrp1.deja.com>

More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4