+1 to what Jelle said -- I don't see anyone seriously using this except in code golf or obfuscated code contests.
On Fri, Apr 23, 2021 at 11:51 AM Jelle Zijlstra <jelle.zijls...@gmail.com> wrote: > For what it's worth, Larry's PEP 649 branch currently prohibits yield, > yield from, await, and the walrus operator in annotations. That seems like > the right choice unless there's some realistic use case for any of these. > > El vie, 23 abr 2021 a las 11:27, Batuhan Taskaya (<isidenti...@gmail.com>) > escribió: > >> About 4 months ago, I've created bpo-42725 in order to >> resolve some of the points below though I decided to >> postpone it for various reasons that blocked it completely >> until the point of where we have a beta cut in a week or >> so. So I'm asking for comments regarding how should we resolve >> this behavior. >> >> Even though PEP 563 blocks having all compiler-related activities >> for annotations by behaving them strings, this doesn't happen until >> the symbol is constructed which results with different problems. For >> example you can use yield in annotation, and since PEP 563 will stringify >> it you'd expect your function to act accordingly but it currently doesn't. >> Also references to the upper scope variables will still be contained as >> closures >> of the current function, and some other oddities that I've found >> regarding misc >> stuff (usage of super() etc). >> >> Here is a quick demo: >> >> def foo(): >> for number in range(5): >> foo: (yield number) >> return number >> >> foo() # ======> this will be a generator >> >> We could go with acting these as strings and letting them stay as >> annotations >> but making them no-op on the symbol table (which is the straight forward >> choice) >> or we could restrict usage of those inside of annotations and raise >> SyntaxErrors. I've >> drafted patches for both of those ideas, though it definitely needs >> more work and >> there is not much time left so any comments would be appreciated. >> >> P.S: I intend to submit a PR with the most likely option by, at latest, >> end of >> saturday so that we can give reviewers enough time and also catch the >> beta freeze >> considering this is a clear behavioral change. >> _______________________________________________ >> Python-Dev mailing list -- python-dev@python.org >> To unsubscribe send an email to python-dev-le...@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/5NQH5GURAYW6XINPBO6VSF45CWLQOHUQ/ >> Code of Conduct: http://python.org/psf/codeofconduct/ >> > _______________________________________________ > Python-Dev mailing list -- python-dev@python.org > To unsubscribe send an email to python-dev-le...@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/PZJXENJP2PDZ3OARUEJS5YDQ2HEQ5VI6/ > Code of Conduct: http://python.org/psf/codeofconduct/ > -- --Guido van Rossum (python.org/~guido) *Pronouns: he/him **(why is my pronoun here?)* <http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/>
_______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@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/KBWUTQTHHDNPHWW4WWXBT5IKRA4RQY5R/ Code of Conduct: http://python.org/psf/codeofconduct/