Re: Presenting PEP 695: Type Parameter Syntax
Patrick Reader <[email protected]> Fri, 15 Jul 2022 09:02:11 +0000
| Newsgroups | gmane.comp.python.devel |
|---|---|
| Message-ID | <010201820118150a-c31db91a-ffc3-41ab-9d69-dc5d5d64d403-000000@eu-west-1.amazonses.com> |
On 13/07/2022 14:14, [email protected] wrote: > Hi, I like this PEP but I couldn't find the motivation for using angle brackets over square braces (brackets?). The survey in Appendix A is great but lacks any conclusions. From that survey alone I would assume that angle brackets would have been chosen over square braces, given that they are the most common option and appear in (afaik) the more popular languages in that list. I think the PEP should add a section about the choice of syntax in the rejected section, which can be expanded upon in Appendix A. > > If you can't tell I'm in favor of angle brackets, I think the examples given in the PEP look a bit messy with so many parentheses and square braces in close proximity. Using angle brackets would make the distinction between typevars and function parameters clearer. Another reason that square brackets should be preferred over angle brackets is the difficulty in parsing: list<list<int>> is tokenised as list < list < int >> where the last token is a right shift operator, so the parser has to know that sometimes >> is used when two "angle bracket" groups are closed, instead of > >