[Python-ideas] Re: Argumenting in favor of first()

2019-12-10 Thread Chris Angelico
On Wed, Dec 11, 2019 at 5:14 PM Steven D'Aprano wrote: > > On Tue, Dec 10, 2019 at 07:21:13PM -0600, Tim Peters wrote: > > While the meaning of `first()` is clear for any iterable argument. > > Sorry Tim, I have to disagree. The meaning of `first` is: > > return the first element of a

[Python-ideas] Re: Argumenting in favor of first()

2019-12-10 Thread Steven D'Aprano
On Tue, Dec 10, 2019 at 07:21:13PM -0600, Tim Peters wrote: > [Tim] > >> For me, most of the time, it's to have an obvious, uniform way to > >> spell "non-destructively pick an object from a container (set, dict, > >> list, deque, heap, tuple, custom tree class, ...)". I don't even have > >>

[Python-ideas] Re: Argumenting in favor of first()

2019-12-10 Thread Steven D'Aprano
On Tue, Dec 10, 2019 at 09:47:08PM -0500, Kyle Stanley wrote: > I think itertools.first() is a good example of something that would be > useful and general-purpose enough to be included as a function in > itertools. And I think that this discussion demonstrates why it is so hard to decide which

[Python-ideas] Re: Argumenting in favor of first()

2019-12-10 Thread Guido van Rossum
For the record, more than 80 messages into this thread, I am no longer interested in pursuing this. In any case, this is not the kind of thing Raymond would ever want to see added to itertools. Let's add a recipe for first() to the list of recipes in the itertools docs. If people want to change

[Python-ideas] Re: Argumenting in favor of first()

2019-12-10 Thread Andrew Barnert via Python-ideas
On Dec 10, 2019, at 17:12, Tim Peters wrote: > > [Andrew Barnert ] >> ... >> I think you’re arguing that the philosophy of itertools is just wrong, at >> least for >> the kind of code you usually write with it and the kind of people who usually >> write that code. Is that fair, or am I

[Python-ideas] Re: Argumenting in favor of first()

2019-12-10 Thread Kyle Stanley
Tim Peters wrote: > It's fair enough, although rather than "wrong" I'd say more that it's > inappropriately applying design principles that work well in most of > Python's libraries to an area where they don't. The very fact that > half the itertools docs are devoted to "recipes" kinda suggests

[Python-ideas] Re: Argumenting in favor of first()

2019-12-10 Thread Tim Peters
[Tim] >> For me, most of the time, it's to have an obvious, uniform way to >> spell "non-destructively pick an object from a container (set, dict, >> list, deque, heap, tuple, custom tree class, ...)". I don't even have >> iterators in mind then, except as an implementation detail. [Steven] >

[Python-ideas] Re: Argumenting in favor of first()

2019-12-10 Thread Tim Peters
[Andrew Barnert ] > ... > I think you’re arguing that the philosophy of itertools is just wrong, at > least for > the kind of code you usually write with it and the kind of people who usually > write that code. Is that fair, or am I misrepresenting you here? It's fair enough, although rather

[Python-ideas] Re: Argumenting in favor of first()

2019-12-10 Thread Steven D'Aprano
On Tue, Dec 10, 2019 at 03:50:19PM -0600, Tim Peters wrote: > For me, most of the time, it's to have an obvious, uniform way to > spell "non-destructively pick an object from a container (set, dict, > list, deque, heap, tuple, custom tree class, ...)". I don't even have > iterators in mind then,

[Python-ideas] Re: Argumenting in favor of first()

2019-12-10 Thread Andrew Barnert via Python-ideas
On Dec 10, 2019, at 13:50, Tim Peters wrote: > > Talking about "needed" is treating this like an axiomatic system where > redundancy is in Very Bad Taste. But, to the contrary, in functional > languages the _implementers_ think very hard about creating a minimal > core, but the user interface

[Python-ideas] Re: Argumenting in favor of first()

2019-12-10 Thread Steven D'Aprano
On Mon, Dec 09, 2019 at 07:12:20PM -0600, Tim Peters wrote: > Part of it, but I believe it's more following prior art, like Haskell's take: > > http://zvon.org/other/haskell/Outputprelude/take_f.html > > In that language, the case for putting the count first is > overwhelming: all functions in

[Python-ideas] Re: Fwd: Re: Argumenting in favor of first()

2019-12-10 Thread Steven D'Aprano
On Mon, Dec 09, 2019 at 10:19:43PM -0400, Juancarlo Añez wrote: > And knowing that you must use *iter()* for 2-arg *next()* to (maybe) work > right is idiosyncratic. If you think that knowing to use `iter` before calling `next` is somehow advanced or difficult knowledge, I think that you have

[Python-ideas] Re: Argumenting in favor of first()

2019-12-10 Thread Tim Peters
[Brett Cannon ] > Thinking out loud here... > > What idiom are we trying to replace with one that's more obviously and whose > semantics are easy to grasp? For me, most of the time, it's to have an obvious, uniform way to spell "non-destructively pick an object from a container (set, dict, list,

[Python-ideas] Re: Argumenting in favor of first()

2019-12-10 Thread Brett Cannon
On Mon, Dec 9, 2019 at 9:43 PM Tim Peters wrote: > [Guido] > > The argument that first(it) and next(it) "look the same" doesn't convince > > me; > > I'm sorry - I guess then I have absolutely no idea what you were > trying to say, and read it completely wrong. > > > if these look the same then

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

2019-12-10 Thread Kyle Stanley
> It also interns many ints, and they can't be used as names at all. To clarify on "many ints", integers in the range of -5 to 256 (inclusive) are interned. This can be demonstrated with the following: ```py >>> a = 256 >>> b = 256 >>> a is b True >>> a = 257 >>> b = 257 >>> a is b False >>> a =