generator/coroutine terminology

Chris Angelico rosuav at gmail.com
Sat Mar 14 12:51:48 EDT 2015


On Sun, Mar 15, 2015 at 3:33 AM, Rustom Mody <rustompmody at gmail.com> 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?

ChrisA



More information about the Python-list mailing list