On Fri, May 4, 2018 at 4:36 AM, Robert Roskam <raiderrob...@gmail.com> wrote: > Hey Chris, > > So I started extremely generally with my syntax, but it seems like I should > provide a lot more examples of real use. Examples are hard. Here's my > hastily put together example from an existing piece of production code: > > > # New Syntax for same problem > > > def convert_time_to_timedelta_with_match(unit:str, amount:int, now:date): > return match unit: > 'days', 'hours', 'weeks' => timedelta(**{unit: amount}) > 'months' => timedelta(days=30 * amount) > 'years' => timedelta(days=365 * amount) > 'cal_years' => now - now.replace(year=now.year - amount)
Okay, here we may have a problem. You're expecting a comma separated set of values to indicate "any of these", but elsewhere, pattern matching against a list of values is making an assertion about a tuple. So if you have any pattern matching that isn't based on equality, you're going to need to clearly stipulate how your syntax works. If you are NOT going to support tuple pattern matching (but only dict), you'll need to make this VERY clear, because people are going to expect it. 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/