Live data from Hacker News

What’s New in Python 3.8

docs.python.org

321–330 of 381 posts

Re: What’s New in Python 3.8

#321
post #307

Earlier quoted context omitted.

I don't understand why anyone would want singledispatch. Instead of having the function defined in one place where you can look it up, now the function is potentially scattered all over the place. (I'm not talking hypothetically. I've had the 'pleasure' of working on a codebase where different singledispatch cases of the same function were defined in different files!)

Because if you need to branch based on type more than a few times in your function it can get pretty hard to read. Am I right that the basis of your complaint is that it's now harder to find all the members of (what you'd call in C++) the "overload set" for a particular function? If so I can see your point.

Yes, that's my point. And it doesn't really simplify the function itself, it just rearranges it, in the same way you can break up a complex painting into jigsaw pieces and say, "Look, each piece is simple!"

Re: What’s New in Python 3.8

#323
post #316

Earlier quoted context omitted.

> I'm still looking forward to using assignment expressions for testing my re.match() objects. The fact that this is the go-to example that everybody is using in justifying the introduction of the assignment expression convinces me that the real problem lies with the re module's API. (To be clear: I will also be using assignment expressions for this case, but I don't think assignment expressions are really in line wi…

re's API sucks but I'm looking forward to safe dictionary access with assignment as well. No more if my_map.get(key) is not None: // do something with my_map[key]

Here the "better" solution (imo) would be support for pattern matching:

    match my_map.get(key):
      case None:
        // do thing (or nothing, i.e., pass)
      case Some(val):
        // do other thing
Scala seems to have figured out how to get pattern matching over arbitrary data (i.e., not statically-defined algebraic datatypes). I'd like to see this come to Python.

(Normally I'd fight for pattern matching to always provide static type safety guarantees, but in Python it seems completely reasonable to omit such checks.)

EDIT: But you're absolutely right that this is a place where assignment expressions will be used regularly, so thank you for pointing that out!

Re: What’s New in Python 3.8

#324
post #118
post #98

Earlier quoted context omitted.

That's like visual puns, and is limited to whatever symbols seemed important to the developer at the time. How do you discover how to type ß, °, «, ‡ etc? Android's gboard uses phonetics (long press [s] key for ß), symbolic similarity (long press [*] key for ‡) and visual similarity (long press [<] key for «) which is guessable for some symbols, but isn't discoverable for others (you can search for emoji by name, but…

It's easy on the Mac to have a custom or purpose-built keyboard layout that makes sense for the user or context. It's a little harder with X (mostly due to uncoöperative DEs) but still doable.

Self-reply for Kwpolska: Adding layouts to /usr/share/X11/xkb/symbols/ is straightforward (but is necessarily system-wide, and requires root), and I do that. However, for the popular desktop environments, it's like pulling teeth to have that layout treated as first-class with respect to switching and settings.

(On MacOS, putting a .layout file in ~/Library/Keyboard\ Layouts is enough.)

Re: What’s New in Python 3.8

#325
post #313

Earlier quoted context omitted.

Instead of raising StopIteration you could also just return from the function. You could also make it a bit shorter if you swap the if branches. def f_iter(many, args): while True: m = f(many, args) if not m: return yield m

Instead of raising StopIteration you have to return from the function, otherwise you'll just get a RuntimeError starting with Python 3.7.

You're right. The [changelog] for Python 3.7 states:

> [bpo-32670]: Enforce [PEP 479] for all code. This means that manually raising a StopIteration exception from a generator is prohibited for all code, regardless of whether ‘from __future__ import generator_stop’ was used or not.

[changelog]: https://docs.python.org/3.7/whatsnew/changelog.html#id115

[bpo-32670]: https://bugs.python.org/issue32670

[PEP 479]: https://www.python.org/dev/peps/pep-0479/

Re: What’s New in Python 3.8

#326

Earlier quoted context omitted.

Yeah right, because splitting the community hasn't caused any problems at all... Get a grip; you are failing at whatever your job is if you're responsible for a python2 project and haven't moved it to python3 by now.

Python3 was a bad idea. Guido himself acknowledged it. There was no point in breaking everything. The split was initiated by core developers, not by the community.

Sorry, not good enough. The decision was made, good or bad, 11 years ago. Everyone had plenty of time to come to grips with that reality, anyone still lingering on Python2 is bad at their job.

The bad decision now is to allow the split to continue, and RedHat is allowing that to happen due to greed and ignorance.

Re: What’s New in Python 3.8

#327

Earlier quoted context omitted.

I feel the same way as you do. For me, which version of an interpreter I'm using should be the kind of issue I only need to worry when solving extremely specific, deep-level problems. Python 3+ breaks this pact too often for my taste. Considering this f-string example taken from another announcement: f"Diameter {(diam := 2 * r)} gives circumference {math.pi * diam:.2f}" This is valid Python 3.8, but it's not valid in…

I'm not sure why you frame this as an issue with Python 3. This has always been the case, even in the 2.x days every release added new features, and if you ran code using them in an older version it wouldn't work. The minor releases are always backward-compatible, so just run the latest version and everything will work.

The issue is that the ecosystem as a whole tends to follow the tip of the version chain. This means that any human-oriented Python stuff (e.g. documentation/tutorials/code-review/etc...) requires you stay up to date with the language changes.

Asyncio was the worst culprit, as it essentially introduces an inner-platform with its own dataflow semantics, but at least there the upsides were large and tangible.

Re: What’s New in Python 3.8

#328

Earlier quoted context omitted.

Because of the luddites at RedHat, Python2.7 isn't actually dead until 2024. It's infuriating. https://access.redhat.com/solutions/4455511

If you want other people to make a change then it's on you to make a convincing argument for why the new thing is an improvement, not just go on tirades about how people should get with the times. Personally, I lost faith in the Python core team because of the Py3 migration. Yes, 3.x now has a bunch of nice features that 2.x did, but almost none of them actually depend on the 3.0's breakage (as proven by Tauthon). If…

I've done that; this isn't the first time I've talked about this problem. HN is not a safe space, there is no room to convince anyone of anything on here, so tirades are all that's left.

We're well past your argument. It's been 11 years, it is no longer reasonable to hold your particular grudge. Get on board with the modern Python or get the hell out of the conversation.

Re: What’s New in Python 3.8

#329

Earlier quoted context omitted.

Not misunderstood; luddites (lowercase l, or at least the generalized form) means something different than Luddites (capitalized L).

I'm fairly certain the lowercase l version is the same, but the Luddites are remembered as being ant technology, not pro labour.

A luddite, generally, is one who is anti-technology. A Luddite, specifically, is a member of a 19th century movement to prevent automation from taking their job.

It's insanely pedantic to try and point out the difference, given the ease with which one can find the generic definition.

Re: What’s New in Python 3.8

#330

Earlier quoted context omitted.

https://docs.python.org/3.0/library/bisect.html > This module provides support for maintaining a list in sorted order without having to sort the list after each insertion.

Problem with bisect is that bisect.insort() insertion is O(n), whereas C++ set.insert() is O(log n).

With respect, I think you're worng about that.

> The module [bisect] ... uses a basic bisection algorithm to do its work.

~ https://docs.python.org/3.0/library/bisect.html

> Binary search runs in logarithmic time in the worst case, making O(log n) comparisons...

~ https://en.wikipedia.org/wiki/Binary_search_algorithm

edit: Unless you mean moving the data?

Post reply on HN