On Sat, 17 Sept 2022 at 09:40, Michael Scott Cuthbert <[email protected]> wrote: > > Very late addition to these long threads -- I'm loving the proposal. I'm > rather surprised though that the typing advantages of the pep have not been > emphasized enough.
That would be because I personally don't use that kind of strict typing, so it's not something I'm really qualified to talk about. Would you like to write up a paragraph or two about it? I could incorporate it verbatim, if you like. > I have a lot of code that in order to get correct typing in a strict mode > does something like this: > > ``` > def move_pitches(pitches: list[Pitch]|None = None): > non_none_pitches: list[Pitch] > if pitches is None: > non_none_pitches = [] > else: > non_none_pitches = pitches > ``` > > with the PEP, the typing becomes: > > ``` > def move_pitches(pitches: list[Pitch] => []): > ... > ``` > > and not only is the variable typed properly and more simply from the start, > but I get to use my preferred variable name throughout. > Yeah, that is definitely an advantage, without a doubt! ChrisA _______________________________________________ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/[email protected]/message/MHCXH6T7LGRRA2V2RVBJJH4ECNW34U2C/ Code of Conduct: http://python.org/psf/codeofconduct/
