On 23 March 2018 at 20:01, Chris Angelico <ros...@gmail.com> wrote:
> Apologies for letting this languish; life has an annoying habit of
> getting in the way now and then.
> Feedback from the previous rounds has been incorporated. From here,
> the most important concern and question is: Is there any other syntax
> or related proposal that ought to be mentioned here? If this proposal
> is rejected, it should be rejected with a full set of alternatives.

I was writing a new stdlib test case today, and thinking about how I
might structure it differently in a PEP 572 world, and realised that a
situation the next version of the PEP should discuss is this one:

    # Dict display
    data = {
        key_a: 1,
        key_b: 2,
        key_c: 3,

    # Set display with local name bindings
    data = {
        local_a := 1,
        local_b := 2,
        local_c := 3,

    # List display with local name bindings
    data = {
        local_a := 1,
        local_b := 2,
        local_c := 3,

    # Dict display
    data = {
        key_a: local_a := 1,
        key_b: local_b := 2,
        key_c: local_c := 3,

    # Dict display with local key name bindings
    data = {
        local_a := key_a: 1,
        local_b := key_b: 2,
        local_c := key_c: 3,

I don't think this is bad (although the interaction with dicts is a
bit odd), and I don't think it counts as a rationale either, but I do
think the fact that it becomes possible should be noted as an outcome
arising from the "No sublocal scoping" semantics.


P.S. The specific test case is one where I want to test the three
different ways of spelling "the current directory" in some sys.path
manipulation code (the empty string, os.curdir, and os.getcwd()), and
it occurred to me that a version of PEP 572 that omits the sublocal
scoping concept will allow inline naming of parts of data structures
as you define them.

Nick Coghlan   |   ncogh...@gmail.com   |   Brisbane, Australia
Python-ideas mailing list
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to