generator/coroutine terminology

Rustom Mody rustompmody at gmail.com
Sat Mar 14 13:17:40 EDT 2015


On Saturday, March 14, 2015 at 10:22:51 PM UTC+5:30, Chris Angelico wrote:
> On Sun, Mar 15, 2015 at 3:33 AM, Rustom Mody wrote:
> > As best as I can see python makes no distinction between such a foo and
> > the more usual function/methods that have no returns.
> > You can I can talk about these and distinguish them
> > Python has no clue about it.
> 
> But what support is actually needed? Look, I can write functions that
> return values:
> 
> def square(x):
>     return x*x
> 
> four = square(2)
> 
> and functions that don't:
> 
> def save_to_file(fn):
>     with open(fn, "w") as f:
>         f.write(stuff)
>         f.write(more_stuff)
> 
> save_to_file("/tmp/asdf")
> 
> Who cares that the second one actually returns None and then ignores
> that? It's not returning anything, it's not using the function return
> value. This is, in effect, a procedure.
> 
> How is Python worse off for doing things this way rather than having a
> true "function with no return value" or "procedure" concept?

Well...
We can talk about that... maybe in another thread...
My more pressing question is that when I try to read the explanations of
generators, my tongue gets stuck behind my ears. And I suspect the problem is 
with the terminology

My original question was quite genuine:
Thanks to Marko's collections from the docs and also Steven's
> That glossary entry is misleading, or at least incomplete, and it fails to
> match the way "generator" is used by actual Python programmers. 

I guess I can confirm that the docs are messy the concepts are confused
and we (teachers) have to do whatever we will with that state of affairs.

[I admit to even having (tried to) teach C++. But I would not try to repeat that
feat if I had a choice]



More information about the Python-list mailing list