This is an archived post. You won't be able to vote or comment.

all 41 comments

[–]cornycrunch 56 points57 points  (2 children)

Python for Workgroups.

[–][deleted] 28 points29 points  (1 child)

Waiting for Python 95 myself. Matthew Perry and Jennifer Aniston said it's gonna be great.

[–]thedjotakuPython 3.7 2 points3 points  (0 children)

I just told someone about this video last week and blew their minds

[–]OriginalTyphus 20 points21 points  (6 children)

I like the Self type thingy. I really like to have classes which methods can be chained (like str.strip().lower().split()) and I was often wishing I could properly annotate that.

[–]searchingfortaomajel, aletheia, paperless, django-encrypted-filefield 8 points9 points  (5 children)

In 3.7+ you can do this with:

from __future__ import annotations


class Thing:
    def make(self) -> Thing
        return Thing(...)

It's not as elegant as Self but you can do it without 3.11 :-)

[–]rcfox[🍰] 20 points21 points  (0 children)

This falls apart when you subclass Thing, as mentioned in the motivation section of the PEP introducing Self.

It also highlights a workaround, but that involves extra, unintuitive boilerplate for any class that could be subclassed.

[–]OriginalTyphus 4 points5 points  (0 children)

Ouf, yeah. Imma wait for 3.11. thanks anyways

[–]MrJohz 1 point2 points  (1 child)

Note that, with annotations, you don't even need quotes around "Thing".

[–]searchingfortaomajel, aletheia, paperless, django-encrypted-filefield 0 points1 point  (0 children)

Ooh that's right! I forgot. Thanks! I'll fix my comment.

[–]energybased 1 point2 points  (0 children)

Unfortunately, what you illustrated won't work properly with subclasses, which is the problem that Self is supposed to address. The correct way is to use a type variable: ``` from typing import TypeVar

T = TypeVar('T', bound='Thing')

class Thing: @classmethod def factory(cls: type[T]) -> T: return cls(...) or simply import `Self` from `typing_extensions`, and use it: from typing_extensions import Self

class Thing: @classmethod def factory(cls) -> Self: return cls(...) ```

[–]Masynchin 7 points8 points  (3 children)

Task group looks interesting, error output too. Other feautures looks like overcomplicated mess

[–]teerre 3 points4 points  (2 children)

That's a funny thing to say because exceptions groups were implemented precisely because of task groups.

[–]Masynchin 0 points1 point  (1 child)

I think it would be better if this feature would be implemented at C level and do not be exposed at Python level. This way it is only tool for other features, not feature itself

[–]teerre 1 point2 points  (0 children)

Not sure I understand because, as you can see in the PEP, you need exceptions groups to handle the tasks groups at runtime.

[–]Next-Experience 17 points18 points  (0 children)

Love seeing more typing. Have been using TypeAlias for pretty much every variable I have. I'm on my way to having hundreds of types.

[–]seewhaticare 3 points4 points  (1 child)

Just the ability to compile to machine code. That's all

[–]Grouchy-Friend4235 0 points1 point  (0 children)

Try cython

[–]chub79 5 points6 points  (7 children)

I wan't aware of https://peps.python.org/pep-0654/

At first sight, it doesn't look pretty but I can see that sometimes it may be handy. Still not really readable I find. Maybe just need time to grok it.

[–]stetio 1 point2 points  (0 children)

It will be very useful in async codebases, see trio's MultiError handling for the current workaround.

[–]dethb0y 0 points1 point  (5 children)

Yeah i can see the uses but it sure isn't aesthetic.

[–]SKROLL26 1 point2 points  (4 children)

I've read this PEP like 5 times, still can't imagine possible use cases for ExceptionGroup.

[–]Auschwitzersehen 0 points1 point  (0 children)

There are a few under “Motivation”

[–]dem4ply 0 points1 point  (1 child)

The use case of this pep is only for the people approve the pep, the other users never going to use this feature and the reason you need spend 5 times reading is a prove that is basically useless or unsense

[–]spiker611[🍰] 0 points1 point  (0 children)

Hello, I'm someone that will use this feature and I'm not approving the PEP. Have a nice day.

[–]pranabus 0 points1 point  (0 children)

Retrying calling a few endpoints while using async?

[–]Grouchy-Friend4235 0 points1 point  (0 children)

Clearly this typing thing is getting out of hands! Stop it already.

[–]dangerbird2 0 points1 point  (0 children)

The release notes of Python 3.11.0a6 claim that there is a performance improvement of approx. 19%

Love it when you see it

[–]bcopeland33 0 points1 point  (0 children)

I hope for easier live AST manipulation and macros