[Python-Dev] Examples for PEP 572
chris.barker at noaa.gov
Thu Jul 5 17:03:36 EDT 2018
On Wed, Jul 4, 2018 at 7:20 AM, David Mertz <mertz at gnosis.cx> wrote:
> That said, this is a silly game either way. And even though you CAN
> (sometimes) bind in an expression pre-572, that's one of those perverse
> corners that one shouldn't actually use.
not only shouldn't by hardly anyone ever does / would.
A lot of the argument for this feature is that it doesn't really let you do
things you couldn't do before (like manipulate the local namespace in side
comprehensions, or the nonocal one, or...)
But this IS a silly game -- Python is highly dynamic, you can do all sorts
of metaprogamming tricks. I'm pretty sure you can even alter the byte code
in a running interpreter (but only pretty sure, 'cause why would I ever try
to do that?)
But the point is not that you can do tricky namespace manipulations now,
it's that you need to do advanced (and obvious) thinks like call locals()
or globals() or use nonlocal, or...
I don't think these concerns have been ignored, but I also don't think that
I've heard anyone on the pro side say something along the line of:
"Yes, this does add a significant complication to the language, but we
think it will be unlikely to be mis-used in confusing ways, and that
complication is worth it."
Rather, I've heard a lot of "but you can already do that" or "but we added
[ternary expressions, augmented assignment, f-strings, ...]" And none of
those add *complication* to the language itself -- they add one more
feature that needs to be looked up when you encounter it -- but only effect
the line of code where there are used.
Christopher Barker, Ph.D.
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-Dev