[Python-ideas] Delayed Execution via Keyword

David Mertz mertz at gnosis.cx
Fri Feb 17 17:09:26 EST 2017


That was a problem with the colon that occurred to me. I think it can't be
tokenized in function annotations.

Plus I still think the no-colon looks better. But that's bikeshedding. Also
other words are plausible. I like lazy even more than delayed, I think.
Still, I'd love the construct whatever the exact spelling.

On Feb 17, 2017 12:41 PM, "Joshua Morton" <joshua.morton13 at gmail.com> wrote:

> I think it could even be true without, but the colon may cause ambiguity
> problems with function annotations.
>
>    def foo(delayed: delayed: 1 + 2)
>
> is a bit odd, especially if `delayed` is chainable.
>
> --Josh
>
> On Fri, Feb 17, 2017 at 3:32 PM Joseph Hackman <josephhackman at gmail.com>
> wrote:
>
>> Couldn't the same thing be true of delayed if it is always followed by a
>> colon?
>>
>> I.e.
>> delayed=1
>> x= delayed: slow_function()
>> print(delayed) # prints 1
>>
>> -Joseph
>>
>> On Feb 17, 2017, at 2:39 PM, Mark E. Haase <mehaase at gmail.com> wrote:
>>
>> On Fri, Feb 17, 2017 at 1:55 PM, Joshua Morton <joshua.morton13 at gmail.com
>> > wrote:
>>
>> but I'm wondering how common async and await were when that was proposed
>> and accepted?
>>
>>
>> Actually, "async" and "await" are backwards compatible due to a clever
>> tokenizer hack. The "async" keyword may only appear in a few places (e.g.
>> async def), and it is treated as a name anywhere else.The "await" keyword
>> may only appear inside an "async def" and is treated as a name everywhere
>> else. Therefore...
>>
>>     >>> async = 1
>>     >>> await = 1
>>
>> ...these are both valid in Python 3.5. This example is helpful when
>> proposing new keywords.
>>
>> More info: https://www.python.org/dev/peps/pep-0492/#transition-plan
>>
>>
>> _______________________________________________
>> Python-ideas mailing list
>> Python-ideas at python.org
>> https://mail.python.org/mailman/listinfo/python-ideas
>> Code of Conduct: http://python.org/psf/codeofconduct/
>>
>> _______________________________________________
>> Python-ideas mailing list
>> Python-ideas at python.org
>> https://mail.python.org/mailman/listinfo/python-ideas
>> Code of Conduct: http://python.org/psf/codeofconduct/
>
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170217/fb8704b3/attachment.html>


More information about the Python-ideas mailing list