This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Revise generator-related Glossary entries
Type: Stage:
Components: Documentation Versions: Python 3.1, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: georg.brandl, jjposner
Priority: normal Keywords: patch

Created on 2010-02-24 16:15 by jjposner, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
glossary.patch jjposner, 2010-02-24 16:14 Patch file for glossary.rst
Messages (5)
msg100042 - (view) Author: John Posner (jjposner) * Date: 2010-02-24 16:14
Currently, the glossary contains two entries, for "generator" and "generator expression". The accompanying patch changes this to three entries: "generator", "generator function", and "generator expression", and cleans up the relationships:

* generator function returns generator
* generator expression returns generator
msg102148 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2010-04-02 09:12
I think this patch is not correct: a "generator" really is the same as "generator function".  Both generators and genexps return an iterator; I've fixed that in r79587.
msg102187 - (view) Author: John Posner (jjposner) * Date: 2010-04-02 19:16
Georg, your change (r79587) makes this the main definition:

  generator
      A function which returns an iterator.
  
I'm concerned that this definition does not fit well with the occurrence of "generator object" in the following:

Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> obj1 = (x for x in [1,2])
>>> def gfunc():
...     count = 0
...     while True:
...             count += 1
...             yield count
...
>>> obj2 = gfunc()
>>> obj1
<generator object <genexpr> at 0x00CC6378>
>>> obj2
<generator object gfunc at 0x00CC6328>
>>>


My patch attempted to make "generator" be the same as "generator object" in the above.
msg102189 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2010-04-02 19:36
Well, the object returned is "just" an iterator (which happens to be implemented by a generator-iterator).  I wouldn't be so concerned about the repr() of the it.

If you look at the generator PEP, number 255, it says:

"""Note that when the intent is clear from context, the unqualified name
"generator" may be used to refer either to a generator-function or a 
generator-iterator."""

My experience is that most people use "generator" to mean the actual function.  The returned object is mostly called iterator.
msg102207 - (view) Author: John Posner (jjposner) * Date: 2010-04-02 22:15
Fair enough, Georg. Case closed.
History
Date User Action Args
2022-04-11 14:56:58adminsetgithub: 52260
2010-04-02 22:15:19jjposnersetmessages: + msg102207
2010-04-02 19:36:19georg.brandlsetmessages: + msg102189
2010-04-02 19:16:36jjposnersetmessages: + msg102187
2010-04-02 09:12:36georg.brandlsetstatus: open -> closed
resolution: fixed
messages: + msg102148
2010-02-24 16:15:00jjposnercreate