Conditional iteration

Carl Banks pavlovevidence at gmail.com
Thu Dec 14 02:57:10 EST 2006


at wrote:
> Carl Banks wrote:
>
> > at wrote:
> >> Well, all I can say that for me as a user it would make sense...
> >
> > Which is, like, step one out of a hundred for getting a syntax change
> > into the language.
> >
> >> Curiosity: in what sense is it redundant?
> >
> > It creates syntactical support for two different ways to do something.
> > If your plan were adopted, then we'd have two different spellings for
> > the same thing:
> >
> > for i in a:
> >     if i != 0:
> >         use(i)
> >
> > for i in a if i != 0:
> >     use(i)
>
> With the current Python syntax, I can create for every two lines of code a
> dozen alternative implementations:
>
> # example 1
> a = {}
> a['b'] = 'c'
>
> versus:
> a = {'b': 'c'}
>
>
> # example 2
> l = []
> for l in some_list:
>         if some_condition:
>                 l.append(l)
>
> versus:
> l = []
> for x in some_list:
>         if some_condition:
>                 l = l + [x]
>
> or:
> l = [x for x in some_list if some_condition]
>
> (the beautiful one)
>
> So your argument doesn't mean much I would say!

That's a pretty asinine and/or stupid thing for you to say, since you
took my argument completely out of context.  In particular, you ignored
the following paragraph, where I weighed the benefits of the new syntax
versus the cost of redundancy.

Have you done that in your counterexamples?  Did you weigh the
benefits, and somehow conclude that what different the syntaxes in the
counterexamples buy is just as little as what your proposal buys?  No,
you didn't.

Next time, wait till I've actually made my argument before passing
judgment on whether it means anything.


> > Now, redundant syntax isn't a deal breaker by itself.  You have to ask
> > what is buys you.  In this case, all it does is save you a single level
> > of indentation--that's it.  There's no performance benefit.  It doesn't
> > simplify logic.  It doesn't make the code any more readable of clear.
> > It's only a minor improvement in conciseness.  It hardly saves any
> > typing (unless you indent by hand).  Even its one clear benefit, saving
> > indentation, is something you can already get with "if not x:
> > continue".
>
>
> Well there is a clear performance benefit, or more precisely a productivity
> benefit.

Performance and productivity aren't the same thing.  There is no
peformance benefit of your syntax.  Productivity is not so clear cut.
You might be able to argue that there's some marginal productivity
benefit to using your syntax, but I can't imagine it'd be anything
substantial.


> And -please- do not underestimate this for a language like Python,
> which has many supporters due to its perceived and high productivity and
> challenged on this point by languages like Ruby.
>
> 'for x in some_list if some_condition:'
>
> is psychological very strong, because the brain will most likely treat the
> in the same way as :
>
>         for every apple in the fruitbasket take one if green
>
>
> Basically upon reading this first line you know exactly to what list of
> items your next section of code applies.

I don't understand why this wouldn't also apply if the if statement
happens to be on the following line.  I still think all this is is
whining about the extra indentation.


> But again everything is a matter of taste and I assume that's why the change
> control body is put into the hand of one person.
[snip]
> >> Does Guido ever change his mind?
> >
> > Yes, but I guarantee "it makes sense for me" isn't going to convince
> > him.  By the way, I'd suggest when posting to comp.lang.python and/or
> > python-list in the future, you put your replies beneath the quoted text
> > for the benefit of any future readers (not to mention present readers).
>
> I hope this this thread will support the "it makes sense for me" with
> arguments. Again it is not my intention to fight windmills,

I would just stop right now, then.  It's not going to change.

> but to see if
> there are strong arguments against it on one hand and if there supporters
> on the other hand.


Carl Banks




More information about the Python-list mailing list