Sorry, I didn't read it carefully. Anyway, youe example can be written as:
for i in range(5): print(i, end=' => ') if i == 1: print('one') elif i == (2,3):
elif i in (2, 3): print('two or three') elif i > 3: print('more than three')
and it's much simpler to read. I suggested the switch statement for a simpler alternative to the if-elif chain.
On 22 April 2014 17:15, Chris Angelico rosuav-at-gmail.com | python-ideas-at-python.org| email@example.com wrote:
On Wed, Apr 23, 2014 at 1:01 AM, Lucas Malor firstname.lastname@example.org wrote:
for i in range(5): print(i, end=' => ') case = Case(i) if case(1): print('one') elif case((2,3)):
print('tuple(two, three)') elif case(2, 3): print('two or three') elif case > 3: print('more than three') else: print('unmatched')
Ok, but you have to nest it inside a for loop. Your class is a good solution, but a new syntax does not need nesting in a with or a for statement.
I don't think he *has* to nest it. My reading of the above is that it's the For-Case Paradigm , normally considered an anti-pattern but viable for demonstrating what happens in each case.
 http://thedailywtf.com/Articles/The_FOR-CASE_paradigm.aspx _______________________________________________ Python-ideas mailing list Pythonemail@example.com https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/