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. 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.
Since I do about 30% of my work in TypeScript, the idea that `=>` implies that
the right side will be evaluated in some way and returned is a cognitive
lightening not burden.
I do think that the PEP should be stricter in defining whether if an
implementation chooses to do the evaluating in two passes whether normal '='
arguments to the right can or cannot be referenced by late-bound arguments. I
initially read the PEP as saying that you might or might not be able to
reference rightward normal arguments depending on the implementation.
- Michael Scott Asato Cuthbert (music21)
_______________________________________________
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/HL6U6YGJAZQGCXXB3PSFIKEU3CPHE6F2/
Code of Conduct: http://python.org/psf/codeofconduct/