Initializer for set, like dict {} and list []

-/>>> .+\nset\(\)/
+/>>> .+\n\s+set\(\)/
2 Likes

Your regex is not allowing leading spaces before set.

Searching for />>> .+\n *set\(\)/ lang:python yields 1.1k results, which isn’t a huge number but is certainly greater than 61.

2 Likes

Ah that explains it[1].

1.1k is still…really low, honestly. Github code searches are not terribly informative overall, but my baseline is /print\s/ which is 6.1 million files.


  1. can you tell I don’t write doctests? ā†©ļøŽ

3 Likes

I actually didn’t know that you can perform a multi-line search on GitHub by including \n in a regex or I would’ve done this research myself before posting that we need to be more careful when weighing costs vs. benefits. So thanks for that!

With this research, and @effigies’s rightful assessment that most doctests are meant to run against the latest Python versions, it may be safe to say that the costs of the transition are going to be reasonably low.

1 Like

I just found the image that’s been lingering in my mind:

That’s why the {/} looked so familiar, yet strange at the same time. I am now neutral toward the proposal as well! We can decide its meaning in a way that suits us best.

Edit:

Fixed the hard-to-see transparent image in dark mode.

As a mathematician, {/} looks awesome :smiley:

empty_tuple = ()
empty_list  = []
empty_dict  = {}
empty_set   = {/}

Would it be added to Grammar/Tokens as a literal {/} like the Walrus Operator COLONEQUAL ':=' was, or parsed as three separate {, /, } tokens so one could write

my_empty_set = {  /  }

to add in whitespace if they wished?

5 Likes

For consistency with { }, I think it’s better to parse the tokens as separate.

Anyway my impression is that there’s not so much interest in this topic, so I’m doubtful it will be never added to the language.

It seems that there is quite good consensus on this. What would be the next step forward here? Would this need a PEP?

6 Likes

Yes, a PEP would need to be written for eventual submission to the Steering Council. That PEP would need a sponsor.

A

1 Like

Weak consensus among those who have chosen to speak up. Nothing more than that. Which is relevant because…

… the next step is to find a core dev who supports the proposal. Someone who would sponsor a PEP. If you can’t find at least one core dev who’s willing to have their name on the document, it doesn’t have enough support to move forward with.

5 Likes