[Python-ideas] PEP 572: Assignment Expressions (post #4)

Nick Coghlan ncoghlan at gmail.com
Thu Apr 12 09:19:59 EDT 2018


On 12 April 2018 at 07:28, Chris Angelico <rosuav at gmail.com> wrote:
> On Thu, Apr 12, 2018 at 1:22 AM, Nick Coghlan <ncoghlan at gmail.com> wrote:
>>> Frequently Raised Objections
>>> ============================
>>
>> There needs to be a subsection here regarding the need to call `del`
>> at class and module scope, just as there is for loop iteration
>> variables at those scopes.
>
> Hmm, I'm not sure I follow. Are you saying that this is an objection
> to assignment expressions, or an objection to them not being
> statement-local? If the latter, it's really more about "rejected
> alternative proposals".

It's both - accidentally polluting class and module namespaces is an
argument against expression level assignments in general, and sublocal
namespaces aimed to eliminate that downside.

Since feedback on the earlier versions of the PEP has moved sublocal
namespaces into the "rejected due to excessive conceptual complexity"
box, that means accidental namespace pollution comes back as a
downside that the PEP should mention.

I don't think it needs to say much, just point out that they share the
downside of regular for loops: if you use one at class or module
scope, and don't want to export the name, you need to delete it
explicitly.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Python-ideas mailing list