On Tue, Apr 24, 2018 at 11:35:20AM -0400, Yury Selivanov wrote:

> Yes, it would force users to come up with better names *iff* they want
> to use this new sugar:
> 
>   if (first_target = get_first_candidate()) ...
>   elif (second_target = get_second_candidate()) ...

They're not better names. Adding "first_" and "second_" prefixes are 
just meaningless waffle added to the name "target" to satisfy the 
compiler so it doesn't complain about reusing the name.

And it is a clear inconsistency with = as a statement and = as an 
expression:

    # allowed
    target = get_first_candidate()
    if target:
        ...
    else:
        target = get_second_candidate()
        if target: ...


    # refactor, and we get a syntax error
    if (target = get_first_candidate()):
        ...
    elif (target = get_second_candidate()):
        ...


And I cannot even begin to guess whether this will be allowed or not:

    if (target = get_first_candidate()):
        ...
    while (target = get_second_candidate()):
        ...


-- 
Steve
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to