On Thu, May 13, 2021 at 6:38 PM Shreyan Avigyan <pythonshreya...@gmail.com> wrote: > > -1. This would require definition of what is a range and which types it > support. Defining ranges of user-defined classes doesn't make sense and it > would also be hard to implement. >
There are two obvious definitions of a range: a range object, and a pair of inequalities. I'm not sure whether a range object is supported, but it's possible to use a built-in type with a guard as a range check: match thing: case int(n) if 1 <= n < 5: ... Or you can omit the type check and just use the guard: match thing: case n if 1 <= n < 5: ... Whether this is too cumbersome to be useful is up to the OP. (I'm not familiar with Rust so I don't know what "1..=5" means and whether or not each endpoint is included, so if I got the openness of the range wrong, just change whether it's "<=" or "<" as needed.) ChrisA _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/26PLY3O5WPLTHKPKV7EHZKVELD5HEIOH/ Code of Conduct: http://python.org/psf/codeofconduct/