[Python-ideas] Re: Sets for easy interning(?)

2019-12-02 Thread Random832
On Tue, Dec 3, 2019, at 01:02, Kyle Stanley wrote: > However, if the OP wants to personally implement this behavior for > their own subclass of sets (instead of adding it to the language), that > could be done rather easily: The OP wanted to return the object that was in the set. I don't think

[Python-ideas] Re: Where should we put the python-ideas HOWTO?

2019-12-02 Thread Stephen J. Turnbull
Thanks for writing this up! It's nicely done. C. Titus Brown writes: > > On Dec 1, 2019, at 8:15 AM, Jonathan Goble wrote: > > I'd suggest putting the full text on the list sign up page above > > the subscription form (to encourage reading before signing up) > > and perhaps even in the

[Python-ideas] Re: Sets for easy interning(?)

2019-12-02 Thread Kyle Stanley
> FWIW, you can do it with dict already. > o = memo.setdefault(o, o) I don't think this has quite the same behavior as the OP is looking for, since dict.setdefault() will insert the key and return the default when it's not present, instead the OP wanted to raise "KeyError if the object is not

[Python-ideas] Re: Moving PEP 584 forward (dict + and += operators)

2019-12-02 Thread Guido van Rossum
On Mon, Dec 2, 2019 at 8:39 PM Kyle Stanley wrote: > Also, I think it's worth noting that we can optimize the actual behavior > of the in-place operator under the hood, similar to what is done with > consecutive string concatenations [2]. Of course, the optimization wouldn't > be the same as it

[Python-ideas] Re: Suggestion for language addition

2019-12-02 Thread Guido van Rossum
To play the devil's advocate... (1) Using the (possible, future) PEG parser this would be easy to add to the grammar, as long as it's optional. (2) It can actually help readability in some cases, especially when e.g. 'for' and 'if' alternate. (3) I have

[Python-ideas] Re: Moving PEP 584 forward (dict + and += operators)

2019-12-02 Thread Ryan
With regard to | vs +, I honestly think the former would be *easier* for beginners than the latter, because: - Having a behavior that is unrelated to other uses of + would arguably be harder to learn, or at least easier to misunderstand when you first see it. - In the CS class world, many

[Python-ideas] Re: Suggestion for language addition

2019-12-02 Thread Andrew Barnert via Python-ideas
On Mon, Dec 2, 2019 at 3:12 PM Jan Bakuwel wrote: > Code example: > > def func (i: int, j: int, k: int) -> None: > if (i == 3): > while (i < 15): > i += 1 > if (k == 8): > lots of other code (think a page or more) This is your actual

[Python-ideas] Re: Moving PEP 584 forward (dict + and += operators)

2019-12-02 Thread Kyle Stanley
> I don't particularly care about learnability or discoverability in this case -- I don't think beginners should be taught these operators as a major tool in their toolbox (let them use .update()), and for anyone wondering how to do something with a dict without access to the official docs,

[Python-ideas] Re: Suggestion for language addition

2019-12-02 Thread Christopher Barker
This is a nonstarter — meaningful indentation is a pretty baked-in ( and liked ) part of the language. And yes, it’s been brought up many times before on this list. And it already exists: for item in a_sequence: do_some_stuff #end for :-) -CHB PS: I’m pretty sure some has written an

[Python-ideas] Re: Sets for easy interning(?)

2019-12-02 Thread Inada Naoki
FWIW, you can do it with dict already. o = memo.setdefault(o, o) On Tue, Dec 3, 2019 at 9:29 AM Soni L. wrote: > > This is an odd request but it'd be nice if, given a set s = {"foo"}, > s["foo"] returned the "foo" object that is actually in the set, or > KeyError if the object is not present. >

[Python-ideas] Sets for easy interning(?)

2019-12-02 Thread Soni L.
This is an odd request but it'd be nice if, given a set s = {"foo"}, s["foo"] returned the "foo" object that is actually in the set, or KeyError if the object is not present. Even use-cases where you have different objects whose differences are ignored for __eq__ and __hash__ and you want to

[Python-ideas] Suggestion for language addition

2019-12-02 Thread Jan Bakuwel
Hi folks, I have a few decades of experience with software engineering using assembler, C, FORTRAN, Pascal, Ada and a fair number of other languages. I've been using Python as well for a number of years now. Both Pascal and Ada have "end" statements, which make the code (at least for me :-)

[Python-ideas] Re: Moving PEP 584 forward (dict + and += operators)

2019-12-02 Thread Brandt Bucher
Thanks for the detailed feedback and helpful suggestions, Guido. Steven, I’m currently on my honeymoon through the 16th, and won’t be working on this (or anything). Feel free to address these points while I’m out. When I’m back I’ll be happy to touch base and make a PR, update the

[Python-ideas] Re: Where should we put the python-ideas HOWTO?

2019-12-02 Thread Barry Scott
Add a link to the HOWTO into the mailman footer? Barry > On 1 Dec 2019, at 15:45, C. Titus Brown wrote: > > Hi folks, > > sorry, took me more than a few months, but I wrote a draft of a python-ideas > HOWTO here, > > https://hackmd.io/@-6xkuCDkTrSFptQEimAdcg/B1noEGh2H > > Thanks to Eric

[Python-ideas] Moving PEP 584 forward (dict + and += operators)

2019-12-02 Thread Guido van Rossum
A month ago I promised the Steering Council I'd review PEP 584 and promptly got distracted by other things. But here it is, at last. Some procedural things first: you (the PEP authors) should apply to the Steering Council for a formal review. They most likely will assign one of the SC members as