[Python-Dev] '*' instead of 'yield'?

Thomas Wouters thomas@xs4all.net
Mon, 6 Aug 2001 01:12:28 +0200


On Sun, Aug 05, 2001 at 11:54:14AM +0400, Roman Suzi wrote:

> Maybe it will be nicier to have unary * instead of 'yield'
> for generators?

Maybe not. Very certainly not for me, in any case :)

> Example I already posted to c.l.p:

> from __future__ import generators
> import calendar, string
> def calt(year, month):
>     month_cal = calendar.monthcalendar(year, month)
>     * """<B>%s.%s</B>""" % (month, year)
>     * """<TABLE BORDER=1>"""
>     for week in month_cal:
>       * """\n<TR>"""
>       for day in week:
>         * """<TD>%s</TD>""" % (day or "&nbsp;")
>       * """</TR>"""
>     * """</TABLE>"""

This looks so ugly and unreadable to me, it's just not funny. It makes '*'
look like some kind of comment character.

> (This will also enable yields from expressions)

There is no reason for 'yield' not to be an expression. "not" and "and" and
"lambda" and such are all expressions too, remember. But making 'yield' a
statement is a very good choice, in my eyes. What should

   ((yield a) ** (yield b) and (yield c)) ^ (yield e) / yield f

yield ? 'yield' is too similar to 'return' for it not to be a statement.

-- 
Thomas Wouters <thomas@xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!