Earlier quoted context omitted.
Exactly the road C++ tries to go down. How's that for a ringing endorsement?
C++ is one of the most successful languages.
What’s New in Python 3.8
181–190 of 381 posts
Re: What’s New in Python 3.8
#182Earlier quoted context omitted.
There are programming fonts that use ligatures to convert >= to ≥, or -> to →, so the source code remains in ASCII but symbol sequences show as unique Unicode characters. A next step could be for common dev environments to actually convert symbol/key sequences to operators (how do APL programmers do it?) Avoiding ambiguity and semantic overloading of ASCII symbols would surely help beginners (if also given a UI that…
The Mac has provided easy access to symbols since 1984, with nice mnemonics like these: option-= ≠ option- ≥ option-/ ÷ option-o ø option-w ∑ I don't know why other OSes haven't adopted something similar. The first couple of these were even idiomatic in HyperCard's scripting language.
> option-w ∑
This would grate on me every single time I had to use it. It's an S. Put it on option-s.
Re: What’s New in Python 3.8
#183Earlier 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…
Re: What’s New in Python 3.8
#184Re: What’s New in Python 3.8
#185Earlier 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?
Though not a language feature per say, I would love if the language would take on the packaging ecosystem and deliver a ground up approach that isn't just a kludge on a kludge on a kludge.
If you use setuptools and place all your configuration declaratively in setup.cfg it is not that bad.
Re: What’s New in Python 3.8
#186Buried in the notes for the `typing` module: > “Final” variables, functions, methods and classes. See PEP 591, typing.Final and typing.final(). The final qualifier instructs a static type checker to restrict subclassing, overriding, or reassignment: > pi: Final[float] = 3.1415926536 As I understand it, this means Python now has a way of marking variables as constant (though it doesn't propagate into the underlying va…
Re: What’s New in Python 3.8
#187Something like:
r1 = foo(x:=bar)
r2 = baz(x)Re: What’s New in Python 3.8
#188Earlier 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).
Python's heuristics for that are pretty annoying.
Re: What’s New in Python 3.8
#189Earlier quoted context omitted.
C++ is one of the most successful languages.
Despite its flaws, not due to them. Same can be said about e.g. Cobol.
Cobol also was a good idea back in the day. And some of the ideas in Cobol we know recognize as bad _had_ to be tried to gain that recognition.
Re: What’s New in Python 3.8
#190Earlier quoted context omitted.
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…
There is a similar trick that you can use without the walrus operator. I wrote the code many years ago and I am reproducing this from memory, so the code below may be a little off. Define this class: class Any: def __eq__(self, other): self.value = other return True Then you can use an instance of it as the hole in a pattern. My use case was performing peephole optimizations in a simple 6502 assembler. For example, i…