I really like the walrus operator, but I didn't realize how many "you shouldn't do this" and "this is too hard already" cases exist where they are discouraging using the walrus operator.
What’s New in Python 3.8
41–50 of 381 posts
Re: What’s New in Python 3.8
#42I do not know exactly what caused this, but my internal project test-suite got a much appreciated 5% speedup! Thank you Python team!
Re: What’s New in Python 3.8
#43Real Python have a great post out today going through most of the changes: https://realpython.com/python38-new-features/ They have a lot of code samples and examples about how and when to use the new features.Personally, I love the new debugging support in F strings.
Re: What’s New in Python 3.8
#44def f(a, b, /, c, d, *, e, f): Wow: IMHO that is a very ugly syntax to define a fn with 6 parameters, although it looks to be a path dependency on previous decisions (*, and CPython ,/) and clearly there was much discussion of the need for the functionality and the compromises: https://www.python.org/dev/peps/pep-0570/ It amazes me to see how certain features make it into languages via community/committee (octal numb…
For https://www.oilshell.org/ , which has Python/JS-like functions, I chose to use Julia's function signature design, which is as expressive as Python's, but significantly simpler in both syntax and implementation:
Manual:
https://docs.julialang.org/en/v1/manual/functions/index.html...
Comparison:
https://medium.com/@Jernfrost/function-arguments-in-julia-an...
Basically they make positional vs. named and required vs. optional ORTHOGONAL dimensions. Python originally conflated the two things, and now they're teasing them apart with keyword-only and positional-only params.
A semicolon in the signature separates positional and named arguments. So you can have:
func f(p1, p2=0, ...args ; n1, n2=0, ...kwargs)
So p2 is an optional positional argument, while n1 is a required named argument.And then you don't need * and star star -- you can just use ... for both kinds of "splats". At the call site you only need ; if you're using a named arg / kwargs splat.
----
Aside from all the numeric use cases, which look great, Julia has a bunch of good ideas in dynamic language design.
The multiline strings in Julia appear to strip leading space in a way that's better than both Python multiline strings and here docs in shell.
Also Julia has had shell-like "f-strings" since day one (or at least version 1 which was pretty recent). Python has had at least 4 versions of string interpolation before they realized that shell got it right 40 years ago :)
Re: What’s New in Python 3.8
#45This is the release that contains the controversial assignment expressions, which sparked the debate that convinced GvR to quit as BDFL. They didn't select my preferred syntax, but I'm still looking forward to using assignment expressions for testing my re.match() objects. I haven't used 3.8.0 yet but I hope its a good one because 2020 is the year that 2.7 dies and there will be a lot of people switching.
>They didn't select my preferred syntax I don't write much python so there's probably something obvious I'm missing, but I don't see why they didn't use "=". Is there some significant difference between assignment expressions and assignment statements that makes it worth having distinct syntax?
Re: What’s New in Python 3.8
#46As a developer who has primarily developed applications in Python for his entire professional career, I can't say I'm especially excited about any of the "headlining" features of 3.8. The "walrus operator" will occasionally be useful, but I doubt I will find many effective uses for it. Same with the forced positional/keyword arguments and the "self-documenting" f-string expressions. Even when they have a use, it's us…
I actually found an immense use for Walrus - used it to hack Python into doing pattern matching that is way more readable than without it: https://github.com/eveem-org/panoramix (source code for Eveem.org, which is arguably the best decompiler for Ethereum smart contracts out there. you can see a lot of pattern matching in pano/simplify.py , and I found no way to do it without extending the language/walrus while main…
Feels like a case of preferring cleverness over readability/usability/maintainability.
Re: What’s New in Python 3.8
#47def f(a, b, /, c, d, *, e, f): Wow: IMHO that is a very ugly syntax to define a fn with 6 parameters, although it looks to be a path dependency on previous decisions (*, and CPython ,/) and clearly there was much discussion of the need for the functionality and the compromises: https://www.python.org/dev/peps/pep-0570/ It amazes me to see how certain features make it into languages via community/committee (octal numb…
> which itself is a result of limiting ourselves to the ASCII symbols that can be typed I think we're ready for programming languages using some visually good Unicode characters, instead of overloading `[]{}!@#$%^&*()-_/` for everything!
Re: What’s New in Python 3.8
#48I understand that Python can't break all kinds of code (as the 2->3 conversion is still a pain), but still I imagine a Python-esque language without all the warts that Python have with it's 'organic' growth.
Re: What’s New in Python 3.8
#49This is the release that contains the controversial assignment expressions, which sparked the debate that convinced GvR to quit as BDFL. They didn't select my preferred syntax, but I'm still looking forward to using assignment expressions for testing my re.match() objects. I haven't used 3.8.0 yet but I hope its a good one because 2020 is the year that 2.7 dies and there will be a lot of people switching.
>They didn't select my preferred syntax I don't write much python so there's probably something obvious I'm missing, but I don't see why they didn't use "=". Is there some significant difference between assignment expressions and assignment statements that makes it worth having distinct syntax?
[1] https://effbot.org/pyfaq/why-can-t-i-use-an-assignment-in-an...