Python’s lack of a ’switch’ statement has garnered much discussion and even a PEP.

The most popular substitute uses dictionaries to map cases to functions, which ra PEP.

The most popular substitute uses dictionaries to map cases to functions, which requires lots of defs or lambdas. While the approach shown in this script may be O(n) for cases, it aims to duplicate C’s original ’switch’ functionality and structure with reasonable accuracy.


Download from: Homepage




Author:
admin
Time:
Friday, May 30th, 2008 at 5:38 pm
Category:
Programming Methods - Algorithms
Comments:
You can leave a response, or trackback from your own site.
RSS:
You can follow any responses to this entry through the RSS 2.0 feed.
Navigation:

Leave a Reply