[issue18558] Iterable glossary entry needs clarification

2019-10-31 Thread Stephen Paul Chappell
Change by Stephen Paul Chappell : -- nosy: -Zero ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue18558] Iterable glossary entry needs clarification

2017-09-25 Thread Raymond Hettinger
Changes by Raymond Hettinger : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker

[issue18558] Iterable glossary entry needs clarification

2017-09-25 Thread Raymond Hettinger
Raymond Hettinger added the comment: New changeset 01438ed4c22ca150da1cc5c38d83a59b0b6a62a7 by Raymond Hettinger (Miss Islington (bot)) in branch '3.6': [3.6] bpo-18558: Clarify glossary entry for "Iterable" (GH-3732) (#3741)

[issue18558] Iterable glossary entry needs clarification

2017-09-25 Thread Roundup Robot
Changes by Roundup Robot : -- pull_requests: +3728 ___ Python tracker ___

[issue18558] Iterable glossary entry needs clarification

2017-09-25 Thread Raymond Hettinger
Raymond Hettinger added the comment: New changeset 0bf287b6e0a42877b06cbea5d0fe6474d8061caa by Raymond Hettinger in branch 'master': bpo-18558: Clarify glossary entry for "Iterable" (#3732) https://github.com/python/cpython/commit/0bf287b6e0a42877b06cbea5d0fe6474d8061caa --

[issue18558] Iterable glossary entry needs clarification

2017-09-24 Thread Raymond Hettinger
Changes by Raymond Hettinger : -- keywords: +patch pull_requests: +3718 stage: needs patch -> patch review ___ Python tracker

[issue18558] Iterable glossary entry needs clarification

2017-09-24 Thread Raymond Hettinger
Raymond Hettinger added the comment: I'll follow David Murray's suggestion here. The glossary definition of iterable is already very good, it just needs to clarify that the __getitem__() method needs to implement sequence semantics. Anything further is beyond the scope of a glossary entry.

[issue18558] Iterable glossary entry needs clarification

2017-07-17 Thread Terry J. Reedy
Terry J. Reedy added the comment: The problem with the Iterable ABC is that 'iterable' and 'iterator' are *dynamically* defined, with a possibly infinite time required to possibly destructively check either definition. In general, an algorithmic *static* check can only guess whether an

[issue18558] Iterable glossary entry needs clarification

2017-07-17 Thread R. David Murray
R. David Murray added the comment: "things with __getitem__ are clearly iterable" This is false. IMO it should be fixed in the glossary. It should say "or __getitem__ method implementing sequence semantics". That plus the addition to the Iterable docs will close this issue. --

[issue18558] Iterable glossary entry needs clarification

2017-07-17 Thread Vedran Čačić
Vedran Čačić added the comment: Yes, the mapping/sequence distinction was (at least declaratively) the reason the ABCs were introduced, but that isn't an obstacle here: whether a mapping or a sequence, it _is_ iterable, right? --- In case anybody is interested, here's how I came to this

[issue18558] Iterable glossary entry needs clarification

2017-07-17 Thread Raymond Hettinger
Raymond Hettinger added the comment: > Or at least, if we cannot do that because of backward > compatibility:-(, to explicitly document that Iterable ABC > _does not_ fully encompass what we mean by "being iterable". That would be a reasonable amendment to collections.abc.Iterable docs. I

[issue18558] Iterable glossary entry needs clarification

2017-07-17 Thread Vedran Čačić
Vedran Čačić added the comment: Raymond, I think you didn't understand the issue. Glossary already _has_ the ammendment you mention (at least for the __getitem__ - I'm not sure any of other examples you mention are counterexamples to that interpretation: callable_iterators and generators _do_

[issue18558] Iterable glossary entry needs clarification

2017-07-17 Thread Raymond Hettinger
Raymond Hettinger added the comment: The wold "iterable" just means "can be looped over". There are many ways to implement this capability (two-arg form of iter(), the __iter__ method, generators, __getitem__ with integer indexing, etc). collections.abc.Iterable is more limited and that is

[issue18558] Iterable glossary entry needs clarification

2017-07-17 Thread Vedran Čačić
Vedran Čačić added the comment: Of course. The Deceptive class was just reductio ad absurdum. I'm all for believing the class through what attributes does it expose. We agree there. Where we don't agree, is _what_ attributes constitute the iteration protocol. You, the source code and the

[issue18558] Iterable glossary entry needs clarification

2017-07-17 Thread R. David Murray
R. David Murray added the comment: No, refusing to guess in this case is to believe the class's declaration that it is an iterable if (and only if) it defines __iter__, which is the modern definition of iterable. If that doesn't work when the object is iterated, that's a bug in the class

[issue18558] Iterable glossary entry needs clarification

2017-07-17 Thread Vedran Čačić
Vedran Čačić added the comment: I think this is backwards. "Refusing the temptation to guess" in this case can mean returning True for is_iterable. After all, we can always have something like class Deceptive: def __iter__(self): raise TypeError("I'm not really

[issue18558] Iterable glossary entry needs clarification

2013-08-01 Thread Stephen Paul Chappell
Stephen Paul Chappell added the comment: If my program needed to know if an object is iterable, it would be tempting to define and call the following function instead of using collections.abc.Iterable: def iterable(obj): try: iter(obj) except TypeError:

[issue18558] Iterable glossary entry needs clarification

2013-08-01 Thread R. David Murray
R. David Murray added the comment: That would give you a false positive, though. It would return True for the 'y' in my example, which is not iterable. So Iterable's behavior here is an example of the Python design rule resist the temptation to guess. As Terry said, new classes should

[issue18558] Iterable glossary entry needs clarification

2013-08-01 Thread Stephen Paul Chappell
Stephen Paul Chappell added the comment: Maybe this would have been more appropriate as a question on StackOverflow: What is the proper way of asking if an object is iterable if it does not support the iterator protocol but does support the old getitem protocol? One might argue that it is

[issue18558] Iterable glossary entry needs clarification

2013-08-01 Thread R. David Murray
R. David Murray added the comment: “What is the proper way of asking if an object is iterable if it does not support the iterator protocol but does support the old getitem protocol?” The *only* answer to that question is to try to iterate it, and see if you get a KeyError on 0. Since this

[issue18558] Iterable glossary entry needs clarification

2013-07-26 Thread Terry J. Reedy
Terry J. Reedy added the comment: Stephen, your class, or rather instances thereof when initialized with a sequence, follow the old iteration protocol. You might call them iterators in the generic sense, though I cannot remember whether we used 'iterator' much before the introduction of the

[issue18558] Iterable glossary entry needs clarification

2013-07-25 Thread R. David Murray
R. David Murray added the comment: The definition of an Iterable is a class that defines an __iter__ method. Your class does not, so the behavior you site is correct. The glossary entry for 'iterable' could use a little clarification. A class that defines __getitem__ is an iterable if and