As 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…
> As 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. Python is a fairly old, mature language. What features would you have been especially excited about?
What’s New in Python 3.8
121–130 of 381 posts
Re: What’s New in Python 3.8
#122Ugh, I hate assignment expressions. I liked that they were missing from Python. I've been coding in algolesque languages for 20 years and hiding assignments inside of expressions instead of putting them on the left like a statement has always tripped me up.
But, but, but... now you don’t need to write that extra line of code! It’s going to make everything sooooo much better, code will practically write itself now. I’ll just leave this here: “There should be one—and preferably only one—obvious way to do it.”
Which is fine by me, it was a silly idea to begin with. What you really want is separated concerns that compose well, obvious here doesn't mean anything over there.
Re: What’s New in Python 3.8
#123Re: What’s New in Python 3.8
#124> In this example, the assignment expression helps avoid calling len() twice: if (n := len(a)) > 10: print(f"List is too long ({n} elements, expected Um, no it doesnt?: a1 = [10, 20, 30] n1 = len(a1) if n1 > 2: print(f'{n1} is greater than two')
Remember: every variable is an assignment into a dict, and every lookup a query into a dict. Reducing name lookups and assignments can yield good speedup in tight loops. For instance, caching os.path.join, os.path.split into local names can significantly speed up tight loops iterating over a filesystem. For example, os.path.split is potentially 5 dictionary lookups. Checking locals, nonlocals and globals for os. Then another to find path, and a final one for split. And this happens at runtime, for every invocation.
Re: What’s New in Python 3.8
#125Disappointing that Python sill has no support for a sorted container in its standard library, akin to C++ `set` or `map` classes.
Re: What’s New in Python 3.8
#126Earlier quoted context omitted.
I may be missing something, but := is still only a 1 character difference, isn't it?
I should have said single-character additions or deletions . == And = have a levenstein distance of 1, == and := is 2. You can't simply make a typo and change an equality check to assignment. So, wiki defines levenstein distance as including substitution, but I was taught or at least remember it only being additions and deletions?
Re: What’s New in Python 3.8
#127As 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…
> As 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. Python is a fairly old, mature language. What features would you have been especially excited about?
Re: What’s New in Python 3.8
#128Earlier quoted context omitted.
Coming from Perl, I used to want this badly, but then I thought that there's absolutely nothing wrong with m = re.match(...) if m is not None: pass Now, I wonder what you meant saying that single-line version is less error-prone, because I don't think so. I believe they're exactly the same in this regard, except for a bizarre case when someone would bastardize the code by putting some irrelevant lines between the ass…
The issue, in my opinion, is when you want something like this: while m := f(many, args): # do stuff with m Now, if you're writing this in Python 3.7, you often end up with some code duplication: m = f(many, args) while m: # do stuff with m m = f(many, args) # duplicate Or something like this: while True: m = f(many, args) if not m: break # do stuff with m Personally, I consider the last version to be the most elegan…
def f_iter(many, args):
while True:
m = f(many, args)
if m:
yield m
else:
raise StopIteration
...
for m in f_iter(many, args):
# do stuff with m
This way you’re isolating all the initialization logic, error handling, etc. And you can focus on your domain logic in your client code.Re: What’s New in Python 3.8
#129Earlier quoted context omitted.
> As 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. Python is a fairly old, mature language. What features would you have been especially excited about?
I'd really like a way to refer to a variable in a outer scope (like global... but not just for global variables).
Re: What’s New in Python 3.8
#130Earlier quoted context omitted.
> 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!
Oh god, this. I want a language that as I type, != Gets replaced with a proper ≠ not equals sign and proper symbols for AND, OR, and NOT.
https://www.hanselman.com/blog/MonospacedProgrammingFontsWit...