[Python-ideas] Re: Opt-in “iter def” and/or “gen def” syntax for generator functions

2022-06-01 Thread Stephen J. Turnbull
Serhiy Storchaka writes: > The advantage is that you cannot accidentally turn a function into a > generator by adding "yield". Can't mypy catch this? > Asynchronous functions are more reliable. "async" is mandatory, and if > you do not await the result of an asynchronous function call you

[Python-ideas] Re: Opt-in “iter def” and/or “gen def” syntax for generator functions

2022-06-01 Thread Serhiy Storchaka
01.06.22 16:59, Chris Angelico пише: On Wed, 1 Jun 2022 at 23:55, Serhiy Storchaka wrote: The advantage is that you cannot accidentally turn a function into a generator by adding "yield". If the result of the call is ignored (it is expected to be None), this bug can live a long time. It is a

[Python-ideas] Re: Opt-in “iter def” and/or “gen def” syntax for generator functions

2022-06-01 Thread Eric V. Smith
On 6/1/2022 9:59 AM, Chris Angelico wrote: On Wed, 1 Jun 2022 at 23:55, Serhiy Storchaka wrote: 31.05.22 16:21, Chris Angelico пише: On Tue, 31 May 2022 at 23:00, Aaron L via Python-ideas wrote: After getting used to writing async functions, I’ve been wanting use a similar syntax to

[Python-ideas] Re: Opt-in “iter def” and/or “gen def” syntax for generator functions

2022-06-01 Thread Chris Angelico
On Wed, 1 Jun 2022 at 23:55, Serhiy Storchaka wrote: > > 31.05.22 16:21, Chris Angelico пише: > > On Tue, 31 May 2022 at 23:00, Aaron L via Python-ideas > > wrote: > >> After getting used to writing async functions, I’ve been wanting use a > >> similar syntax to declare generator functions. > >

[Python-ideas] Re: Opt-in “iter def” and/or “gen def” syntax for generator functions

2022-06-01 Thread Serhiy Storchaka
31.05.22 16:21, Chris Angelico пише: On Tue, 31 May 2022 at 23:00, Aaron L via Python-ideas wrote: After getting used to writing async functions, I’ve been wanting use a similar syntax to declare generator functions. What's the advantage? You can just use normal function syntax to define

[Python-ideas] Typescript-Like Notational Shortcuts

2022-06-01 Thread kevinlu1248
On the theme of the addition of pip operators to indicate union, I was wondering what people think of using the following shortcuts for type hints. * type[] be a short-hand for List[type] * [type1, type2, type3] be a shorthand for Tuple[type1, type2, type3] * similar ideas for dictionaries and

[Python-ideas] Re: Python array multiplication for negative values should throw an error

2022-06-01 Thread Stephen J. Turnbull
fjwillemsen--- via Python-ideas writes: > Of course, such bugs do not occur solely due to the lack of a > raised errors on negative multiplication: in this case, a > combination of a faulty assumption on the programmers' part and > Python's lack of strict typing. I'll take that bait: did