[Python-ideas] [Python-Dev] yield * (Re: Missing operator.call)

nathan binkert nate at binkert.org
Sun Feb 8 20:02:18 CET 2009


> It's not just silly looking, it's the same construct used repeatedly, in
> many different places in code. It is a basic principle of programming that
> anytime you have blocks of code that are almost identical, you should factor
> out the common code into it's own routine. See "Don't Repeat Yourself" and
> "Once And Only Once" for similar ideas:
>
> http://c2.com/cgi/wiki?OnceAndOnlyOnce
> http://c2.com/cgi/wiki?DontRepeatYourself
>

Just to give another random user's opinion, I love this idea.  When
writing code where I factor out lots of generators (for something like
cherrypy), I've had to repeat this two line idiom dozens of times in
one function.

+1

  Nate



More information about the Python-ideas mailing list