On Fri, May 4, 2018 at 12:29 AM, Robert Roskam <raiderrob...@gmail.com> wrote: > Hey Joao, > > Thanks for providing me feedback on this idea! > > For the simplistic example at that you select, yes, you absolutely can do > this as it stands atm. However, the examples I provided further along aren't > as easily accomplished, nor is something like this: > > x = -1 > > result = match x: > x:int if x > 0 => 'greater than 0' > x:int, x:float if x == 0 => 'equal to 0' > x:int if x < 0 => 'less than 0' > > print(result) # 'less than 0' > > > Accomplishing the above with a just a dictionary would be not be the current > Pythonic solution, imo, you'd do it with if/elif:
Correct. So the best way to 'sell' this idea is NOT the simple examples, as they're going to be just as simple with a dictionary. I'd like to see a complete definition of the valid comparisons. Some of your examples are based on equality ("5 => ..." matches the number 5, presumably whether it's an int or a float) and have no variable, others use annotation-like syntax and types to presumably do an isinstance check, and then there's some conditions that I'm not sure about. What are all the options and how would each one be written? How do you combine different options? Is the 'if x == 0' part a modifier to a previous comparison, or is it a separate chained comparison? How does this work? ChrisA _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/