Caveats:
I think it could be very reasonable to want to use dictionary lookups, especially since a lot of older code / libraries use dicts for enum-like use cases.
And arithmetic expressions (outside of powers of 2 and 10):
match unit_value:
case %(7 * 24 * 60 * 60): return “week”
...
And function calls:
match hsv_color:
case %(hsv(“black”)): ...
case %(hsv(“cyan”)): ...
case (_, 0, _): return “some sort of grey”
match git_bisect_action:
case %(config.get_old_term()): ...
case %(config.get_new_term()): ...
match conn:
case %(get_current_conn()): ...
case Connection(host, port): ...
The caveats above apply, and even if you find the above examples compelling, this would probably fall in the 10 bucket of 90/10 usage. But if our syntax for constant value patterns made it natural / easy to support, it’s something to consider, either now or later a la PEP 614.
On Sat, 4 Jul 2020 at 19:15, Chris Angelico rosuav@gmail.com wrote:
On Sun, Jul 5, 2020 at 12:03 PM Shantanu Jain hauntsaninja@gmail.com wrote:
I'm kinda theoretically in favour of expressions, but only the sort that logically "feel" like constants. Unary minus and the addition of real and imaginary parts are already supported, so what's still of value? IMO exponentiation of 2 is usually better spelled in hex (instead of 2**10, use 0x400, unless there's good reason), and since you can have underscores to break up an integer, that handles powers of 10 as well. What notations would you want to use?
ChrisA
Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-leave@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/T24W2FZ6... Code of Conduct: http://python.org/psf/codeofconduct/