Suggested amendment to PEP 255

damien morton morton at dennisinter.com
Wed Jun 20 10:38:28 EDT 2001


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