[Python-ideas] Delayed Execution via Keyword

Joshua Morton joshua.morton13 at gmail.com
Fri Feb 17 16:57:56 EST 2017

Ed, I'm not seeing this perceived problem either.

if we have

    >>> d = delayed {'a': 1, 'b': 2}  #  I'm not sure how this is delayed
exactly, but sure
    >>> k = delayed string.ascii_lowercase[0]
    >>> d[k]

I'm not sure how the delayedness of any of the subexpressions matter, since
evaluating the parent expression will evaluate all the way down.


On Fri, Feb 17, 2017 at 4:53 PM Ed Kellett <edk141 at gmail.com> wrote:

> On Fri, 17 Feb 2017 at 21:21 Joseph Jevnik <joejev at gmail.com> wrote:
> About the "whatever is d[k]" in five minutes comment: If I created an
> explict closure like: `thunk = lambda: d[k]` and then mutated `d` before
> evaluating the closure you would have the same issue. I don't think it is
> that confusing. If you need to know what `d[k]` evaluates to right now then
> the order of evaluation is part of the correctness of your program and you
> need to sequence execution such that `d` is evaluated before creating that
> closure.
> If you create an explicit closure, sure. With delayed expressions, you
> could explicitly delay d[k], too. If you have an existing d and k,
> potentially passed to you by somebody else's code, the delayedness of d and
> k should not inflict arbitrarily-delayed sequencing on your attempt to find
> out what d[k] is now.
> _______________________________________________
> 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/a88107b5/attachment-0001.html>

More information about the Python-ideas mailing list