Michael Chermside wrote: > There is one exception... matching strings. There we have a powerful > means of specifying patterns (regular expressions), and a multi-way > branch based on the content of a string is a common situation. A new > way to write this: > > s = get_some_string_value() > if s == '': > continue; > elif re.match('#.*$', s): > handle_comment() > elif s == 'DEFINE': > handle_define() > elif s == 'UNDEF': > handle_undefine() > elif re.match('[A-Za-z][A-Za-z0-9]*$', s): > handle_identifier() > else: > syntax_error() > > would be might be nice, but I can't figure out how to make it work > more efficiently than the simple if-elif-else structure, nor an > elegent syntax. somewhat related: http://mail.python.org/pipermail/python-dev/2003-April/035075.html </F>
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