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>

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to