Suggested amendment to PEP 255 (fwd)

Dr. David Mertz mertz at gnosis.cx
Wed Jun 20 16:00:15 EDT 2001


One more non-vote for a new spelling of "generator."  Despite
protestations to the contrary by the timbot, I see the very subtle and
late-in-the-definition-body use of 'yield' as a train wreck waiting to
happen.  Never mind newbies, I am certain that *I* would stumble over
the difference between generators and (real) functions all the time.

As spelling goes, I like:

  generator foo(args):

the best.  But the other suggestions below are sufficiently good also.

Yours, David...

-------- Forwarded message --------
Newsgroups: comp.lang.python
Date: 20 Jun 2001 07:38:28 -0700
From: morton at dennisinter.com (damien  morton)
Subject: Re: Suggested amendment to PEP 255

Simon Brunning <SBrunning at trisystems.co.uk> wrote in message news:<mailman.993023610.1418.python-list at python.org>...
> > From:	Greg Ewing [SMTP:greg at cosc.canterbury.ac.nz]
> > I suggest dropping the "def" altogether and using:
> >
> >   generator foo(args):
> >     ...
> >     yield x
> >     ...
>
> This gets my vote. Or it would. If I had a vote. Which I don't.
>
> *Excellent* PEP, BTW!
>
> Cheers,
> Simon Brunning
> TriSystems Ltd.
> sbrunning at trisystems.co.uk

Im 100% with this too. doubleplusgood would be my vote, if I had one.
Generators do seem different enough from functions to warrant a different syntax.

some other syntax possibilities:

gen foo(args):
   yield x

def foo(args) generator:
   yield x

def foo(args) as generator:
   yield x

def generator foo(args):
   yield x




More information about the Python-list mailing list