[Python-ideas] Re: List - append

2020-01-21 Thread Guido van Rossum
Well, mypy is often used primarily as a linter on steroids. Anyway, agreed with your point! On Tue, Jan 21, 2020 at 10:22 AM Andrew Barnert wrote: > On Jan 19, 2020, at 20:54, Guido van Rossum wrote: > > > > Actually, `bar = foo` is more likely to be detected by mypy, since it is > probably a

[Python-ideas] Re: List - append

2020-01-21 Thread Andrew Barnert via Python-ideas
On Jan 19, 2020, at 20:54, Guido van Rossum wrote: > > Actually, `bar = foo` is more likely to be detected by mypy, since it is > probably a type error (unless bar isn't used or is only used in an `Any` > context). For mypy, flagging bare `foo` is harder, because we would have to > introduce

[Python-ideas] Re: List - append

2020-01-20 Thread Steven D'Aprano
On Sun, Jan 19, 2020 at 04:27:30PM -0500, David Mertz wrote: > I'm not sure what you intend here: > > A fluent interface is normally implemented by using method chaining Indeed. *Implemented by*, not "the same as". > to implement method >

[Python-ideas] Re: List - append

2020-01-19 Thread Guido van Rossum
On Sun, Jan 19, 2020 at 8:16 PM Andrew Barnert wrote: > On Jan 19, 2020, at 15:20, Guido van Rossum wrote: > > > On Sun, Jan 19, 2020 at 3:10 PM Tim Peters wrote: > >> [Guido, on Pythons before 1.0.2 always printing non-None expression >> statement results] >> > Heh. That was such a

[Python-ideas] Re: List - append

2020-01-19 Thread Andrew Barnert via Python-ideas
On Jan 19, 2020, at 15:20, Guido van Rossum wrote: > >> On Sun, Jan 19, 2020 at 3:10 PM Tim Peters wrote: >> [Guido, on Pythons before 1.0.2 always printing non-None expression >> statement results] >> > Heh. That was such a misfeature that I had thoroughly suppressed any >> > memory of its

[Python-ideas] Re: List - append

2020-01-19 Thread Christopher Barker
By the way, if anyone is actually interested in this other than for nostalgia , there have been a number of lengthy discussion on this list about "Fluent" interfaces for Python. LIke this one for instance:

[Python-ideas] Re: List - append

2020-01-19 Thread Christopher Barker
On Sun, Jan 19, 2020 at 11:59 AM Tim Peters wrote: > For a bit of history that I may have made up (heh - memory fades over > time!), as I recall, the very first Python pre-releases echoed to > stdout every non-None statement result. which is what MATLAB does, if you don't put a semi-colon at

[Python-ideas] Re: List - append

2020-01-19 Thread Guido van Rossum
On Sun, Jan 19, 2020 at 3:10 PM Tim Peters wrote: > [Guido, on Pythons before 1.0.2 always printing non-None expression > statement results] > > Heh. That was such a misfeature that I had thoroughly suppressed any > > memory of its existence. -k indeed. :-) > > I prefer to think of it as a bit

[Python-ideas] Re: List - append

2020-01-19 Thread Tim Peters
[Guido, on Pythons before 1.0.2 always printing non-None expression statement results] > Heh. That was such a misfeature that I had thoroughly suppressed any > memory of its existence. -k indeed. :-) I prefer to think of it as a bit of genius :-) The natural desire to avoid mounds of useless

[Python-ideas] Re: List - append

2020-01-19 Thread Guido van Rossum
Heh. That was such a misfeature that I had thoroughly suppressed any memory of its existence. -k indeed. :-) On Sun, Jan 19, 2020 at 1:33 PM Tim Peters wrote: > [Guido] > > Sounds like a hallucination or fabrication. > > Nope! Turns out my memory was right :-) > > > The behavior of `for i in

[Python-ideas] Re: List - append

2020-01-19 Thread David Mertz
I should really upgrade to 1.02! % python Python 1.0.1 (Jul 15 2016) Copyright 1991-1994 Stichting Mathematisch Centrum, Amsterdam >>> def f(): ... for i in range(5): i ... >>> f() 0 1 2 3 4 On Sun, Jan 19, 2020 at 4:33 PM Tim Peters wrote: > [Guido] > > Sounds like a hallucination or

[Python-ideas] Re: List - append

2020-01-19 Thread Tim Peters
[Guido] > Sounds like a hallucination or fabrication. Nope! Turns out my memory was right :-) > The behavior of `for i in range(10): i` in the REPL exists > to this day, and list.append() never returned a value. Sure, but those weren't the claims. The claim was that the result of an

[Python-ideas] Re: List - append

2020-01-19 Thread David Mertz
On Sun, Jan 19, 2020 at 3:56 PM Steven D'Aprano wrote: > > The "fluent interface" (https://en.wikipedia.org/wiki/Fluent_interface) > is > > popular in many programming languages, including in the sort of > > "mini-language" Pandas, within portion. > > I can't speak about Pandas, but what the OP

[Python-ideas] Re: List - append

2020-01-19 Thread Andrew Barnert via Python-ideas
On Jan 19, 2020, at 12:15, David Mertz wrote: > > In contrast, in pure Python, most of that you do is in loops over the > elements of collections. In that case is does a good job of drawing your eye > to the fact that a method is called but not assigned to anything. When I see >

[Python-ideas] Re: List - append

2020-01-19 Thread Steven D'Aprano
On Sun, Jan 19, 2020 at 02:37:14PM -0500, David Mertz wrote: > The "fluent interface" (https://en.wikipedia.org/wiki/Fluent_interface) is > popular in many programming languages, including in the sort of > "mini-language" Pandas, within portion. I can't speak about Pandas, but what the OP is

[Python-ideas] Re: List - append

2020-01-19 Thread Steven D'Aprano
On Sun, Jan 19, 2020 at 08:32:43AM -0800, Guido van Rossum wrote: > I'm not excited about suggesting the walrus operator when people want to > chain mutating method calls like this. It results in ugly code with way too > many parentheses and a distinctly un-Pythonic flavor. I hope the OP doesn't >

[Python-ideas] Re: List - append

2020-01-19 Thread Guido van Rossum
Sounds like a hallucination or fabrication. The behavior of `for i in range(10): i` in the REPL exists to this day, and list.append() never returned a value. The only thing I'm only 90% sure of is whether the REPL always ignored None values. On Sun, Jan 19, 2020 at 11:58 AM Tim Peters wrote: >

[Python-ideas] Re: List - append

2020-01-19 Thread Tim Peters
[David Mertz ] > ... > What we get instead is a clear divide between mutating methods > on collections that (almost) always return None, and functions > like sorted() and reversed() that return copies of the underlying > collection/iterable. Of course, there are many methods that don't > have

[Python-ideas] Re: List - append

2020-01-19 Thread David Mertz
The "fluent interface" (https://en.wikipedia.org/wiki/Fluent_interface) is popular in many programming languages, including in the sort of "mini-language" Pandas, within portion. But it is definitely not Pythonic. The Wikipedia article even shows how you *could* do it in Python, but mentions that

[Python-ideas] Re: List - append

2020-01-19 Thread Siddharth Prajosh
On Sun, Jan 19, 2020 at 10:03 PM Guido van Rossum wrote: > I'm not excited about suggesting the walrus operator when people want to > chain mutating method calls like this. It results in ugly code with way too > many parentheses and a distinctly un-Pythonic flavor. I hope the OP doesn't > go off

[Python-ideas] Re: List - append

2020-01-19 Thread Guido van Rossum
I'm not excited about suggesting the walrus operator when people want to chain mutating method calls like this. It results in ugly code with way too many parentheses and a distinctly un-Pythonic flavor. I hope the OP doesn't go off and infect a whole subcommunity with this idiom. On Sat, Jan 18,

[Python-ideas] Re: List - append

2020-01-19 Thread Siddharth Prajosh
On Sun, 19 Jan, 2020, 11:35 Inada Naoki, wrote: > On Sun, Jan 19, 2020 at 2:45 PM Siddharth Prajosh > wrote: > > > > Moreover, shouldn't it work? > > How do I add that feature in Python? > > How you can do it with warus operator. > > >>> (xs := list(range(10))).append(42) > >>> xs > [0, 1, 2,

[Python-ideas] Re: List - append

2020-01-18 Thread Inada Naoki
On Sun, Jan 19, 2020 at 2:45 PM Siddharth Prajosh wrote: > > Moreover, shouldn't it work? > How do I add that feature in Python? How you can do it with warus operator. >>> (xs := list(range(10))).append(42) >>> xs [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 42] Regards, -- Inada Naoki

[Python-ideas] Re: List - append

2020-01-18 Thread Tim Peters
[M Siddharth Prajosh ] > This is more of a doubt than a new idea. Python has always worked > intuitively but this was a bummer. > > A list has an append method. So I can do list.append(value). > I tried doing list(range(10)).append(10) and it returns None. Yes. Most methods that mutate an object