[Python-Dev] assignment expressions: an alternative proposal (original) (raw)
Chris Angelico rosuav at gmail.com
Tue Apr 24 13:24:10 EDT 2018
- Previous message (by thread): [Python-Dev] assignment expressions: an alternative proposal
- Next message (by thread): [Python-Dev] assignment expressions: an alternative proposal
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Wed, Apr 25, 2018 at 2:57 AM, Steven D'Aprano <steve at pearwood.info> wrote:
On Wed, Apr 25, 2018 at 02:42:08AM +1000, Chris Angelico wrote:
> from math import * > process(arg, (pi = 1), pi+1) # allowed
That's not allowed at local scope (at least, it's not allowed at function scope - is there any other "local scope" at which it is allowed?). Of course: local just means the current scope, wherever you happen to be. Inside a function, local is the current function scope. Inside a class body, local is the class body scope. At the top level of the module, local means the module scope (and locals() returns the same dict as globals()). If Yury means for this "cannot mask existing variables" to only operate inside functions, that means that you can mask existing variables if you use assignment expressions in class bodies or top-level module code.
I don't have a quote for it, but I was under the impression that this shielding was indeed function-scope-only.
Actually, now that I think about it, I'm not sure whether Yuri's plan for assignment expressions even included module scope.
ChrisA
- Previous message (by thread): [Python-Dev] assignment expressions: an alternative proposal
- Next message (by thread): [Python-Dev] assignment expressions: an alternative proposal
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]