[Python-3000] List-Comp style for loops?

Crutcher Dunnavant crutcher at gmail.com
Sat Apr 8 21:31:23 CEST 2006


On 4/8/06, Ronald Oussoren <ronaldoussoren at mac.com> wrote:
>
> On 8-apr-2006, at 5:44, Guido van Rossum wrote:
>
> > On 4/7/06, Crutcher Dunnavant <crutcher at gmail.com> wrote:
> >> Basic idea:
> >>
> >> [for ... in ...]+ if ...:
> >>   body
> >>
> >> A) it should be syntatically simple to parse.
> >> B) it establishes a nice symetry with list comprehensions.
> >
> > Are you in cahoots with the person who posted the first response to my
> > Artima blog on today? :-)
> > (http://www.artima.com/forums/flat.jsp?forum=106&thread=155514)
> >
> > I can't make heads or tails of this. What is it supposed to do? What
> > is it supposed to replace?
>
> My guess is that he doesn't get generic/overloaded/extensible functions
> and proposes a way to extend function bodies through some very odd
> syntax.
>
> foo = if x:
>     print "x!"
>
> foo += elif y:
>     print "y!"
>
> would probably be get you a function like this:
>
> def foo():
>     if x:
>       print "x!"
>     elif y:
>       print "y!"
>
> I'd say this wouldn't be an improvement to python ;-)

Perhaps Guido's poster is suggesting this, but I'm not. I don't want
assignment from loops, I just want the same semantics we get in list
comps in the for ... if ... section.

> >
> > --
> > --Guido van Rossum (home page: http://www.python.org/~guido/)
> > _______________________________________________
> > Python-3000 mailing list
> > Python-3000 at python.org
> > http://mail.python.org/mailman/listinfo/python-3000
> > Unsubscribe: http://mail.python.org/mailman/options/python-3000/
> > ronaldoussoren%40mac.com
>
>


--
Crutcher Dunnavant <crutcher at gmail.com>
littlelanguages.com
monket.samedi-studios.com


More information about the Python-3000 mailing list