for i in range(5):print(i, end=' => ')if i == 1:print('one')elif i == (2,3):
print('tuple(two, three)')
elif i in (2, 3):print('two or three')elif i > 3:print('more than three')
else:
print('unmatched')
On Wed, Apr 23, 2014 at 1:01 AM, Lucas Malor <7vsfeu4pxg@snkmail.com> wrote:I don't think he *has* to nest it. My reading of the above is that
>> 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.
>
it's the For-Case Paradigm [1], normally considered an anti-pattern
but viable for demonstrating what happens in each case.
ChrisA
[1] http://thedailywtf.com/Articles/The_FOR-CASE_paradigm.aspx
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/