[Python-ideas] Re: Documenting iterators vs. iterables

2020-05-17 Thread Stephen J. Turnbull
Steven D'Aprano writes: > constructed from Thank you! This is what I will use. "Construction" in programming has the strong connotation of returning a new object (even though, say, int("1") may return an interned object, so not new in a sense). I'm not sure whether I'll rely on that loose

[Python-ideas] Re: Documenting iterators vs. iterables [was: Adding slice Iterator ...]

2020-05-17 Thread Stephen J. Turnbull
Andrew Barnert writes: > >> The answer is that files are iterators, while lists are… well, > >> there is no word. > > > > As Chris B said, sure there are words: File objects are *already* > > iterators, while lists are *not*. My question is, "why isn't that > > instructive?" > > Well,

[Python-ideas] Re: Documenting iterators vs. iterables [was: Adding slice Iterator ...]

2020-05-15 Thread Andrew Barnert via Python-ideas
On May 14, 2020, at 20:17, Stephen J. Turnbull wrote: > > Andrew Barnert writes: > >> Students often want to know why this doesn’t work: >> with open("file") as f: >> for line in file: >> do_stuff(line) >> for line in file: >> do_other_stuff(line) > > Sure.

[Python-ideas] Re: Documenting iterators vs. iterables

2020-05-15 Thread Christopher Barker
I think maybe some of the trouble here, particularly in teaching is the word "is" (in English, not the Python keyword). As in: "A file object IS and iterator" and "A zip object IS an iterator" I know in OO parlance, "is a" can be used to designate subclassing (or an appropriate use for it) and i

[Python-ideas] Re: Documenting iterators vs. iterables [was: Adding slice Iterator ...]

2020-05-15 Thread Jonathan Fine
Oops, try again; Here's an article about recent research. I found it fascinating. https://www.quantamagazine.org/ideal-glass-would-explain-why-glass-exists-at-all-20200311/ It starts: Glass is anything that’s rigid like a crystal, yet made of disordered molecules like a liquid. To understand why

[Python-ideas] Re: Documenting iterators vs. iterables [was: Adding slice Iterator ...]

2020-05-15 Thread Jonathan Fine
Here's an article about recent research: ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://ma

[Python-ideas] Re: Documenting iterators vs. iterables [was: Adding slice Iterator ...]

2020-05-15 Thread Greg Ewing
On 16/05/20 12:26 am, Steven D'Aprano wrote: Arguments over the precise definition of states of matter are, to some degree, futile. I've seen amorphous solids described as "liquids that don't flow" and non-Newtonian liquids described as "solids that flow". I think this just shows that nature d

[Python-ideas] Re: Documenting iterators vs. iterables [was: Adding slice Iterator ...]

2020-05-15 Thread David Mertz
On Thu, May 14, 2020, 11:20 PM Stephen J. Turnbull > > I can teach a child why a glass will break permanently when you hit > > it while a lake won’t by using the words “solid” and “liquid”. > > Terrible example, since a glass is just a geologically slow liquid. ;-) > It isn't though. I used to

[Python-ideas] Re: Documenting iterators vs. iterables

2020-05-15 Thread Steven D'Aprano
On Fri, May 15, 2020 at 05:58:16AM -0400, Ricky Teachey wrote: > Perhaps use the iter function name as the generic? "itered". As opposed to > "iterated" or "iterated over". > > Example: > > "the statement below iterates over an iterator, itered from a sequence" Or just avoid the issue: "The st

[Python-ideas] Re: Documenting iterators vs. iterables [was: Adding slice Iterator ...]

2020-05-15 Thread Steven D'Aprano
On Fri, May 15, 2020 at 12:17:56PM +0900, Stephen J. Turnbull wrote: > Terrible example, since a glass is just a geologically slow liquid. ;-) That's a myth :-) The key test for a liquid is not whether is flows, since solids also flow. (In solids, this usually happens very, very slowly, and is

[Python-ideas] Re: Documenting iterators vs. iterables

2020-05-15 Thread Ricky Teachey
On Fri, May 15, 2020 at 5:37 AM Chris Angelico wrote: > On Fri, May 15, 2020 at 7:23 PM Stephen J. Turnbull > wrote: > > > > Chris Angelico writes: > > > > > I don't like this term "converted". > > > > I refuse to die on that hill. :-) Suggest a better term, I'll happily > > use it until somet

[Python-ideas] Re: Documenting iterators vs. iterables

2020-05-15 Thread Chris Angelico
On Fri, May 15, 2020 at 7:23 PM Stephen J. Turnbull wrote: > > Chris Angelico writes: > > > > (Technical note: for the convenience of implementors of 'for', > > > when iter is applied to an iterator, it always returns the > > > iterator itself.) > > > > That's not a mere technical

[Python-ideas] Re: Documenting iterators vs. iterables

2020-05-15 Thread Stephen J. Turnbull
Chris Angelico writes: > > (Technical note: for the convenience of implementors of 'for', > > when iter is applied to an iterator, it always returns the > > iterator itself.) > > That's not a mere technical detail - that's actually part of the > definition of an iterator, namely

[Python-ideas] Re: Documenting iterators vs. iterables [was: Adding slice Iterator ...]

2020-05-14 Thread Chris Angelico
On Fri, May 15, 2020 at 1:19 PM Stephen J. Turnbull wrote: > ISTM that all we need to say is that > > 1. An *iterator* is a Python object whose only necessary function is > to return an object when next is applied to it. Its purpose is to > keep track of "next" for *for*. (It might do o