[Python-ideas] for/except/else syntax
george.sakkis at gmail.com
Fri Oct 9 05:28:29 CEST 2009
On Thu, Oct 8, 2009 at 8:09 PM, Yuvgoog Greenle <ubershmekel at gmail.com> wrote:
> I agree with you on "then" giving no clues but I think you're wrong
> about the spelling. The correct spelling would be "if not break".
> x = y / z
> if condition:
> The above code translated to "George Sakkis Language" should be spelled:
> x = y / x
> if condition and notreturnandnotexception:
Um, false analogy. The "condition" expression either doesn't raise an
expression and it is evaluated in boolean context, or it does raise an
exception and there is no value to evaluate. Or to put it otherwise,
if "condition" evaluates to True, the hypothetical
"notreturnandnotexception" is also True by definition.
Regardless, even if I accepted that we don't need to emphasize the
exception/return case, I'd be -1 on abusing the "break" keyword to
allow "if not break". Using three keywords to express a single case is
a bad design smell IMO.
> So your spelling exaggeration doesn't worry me :). The fact that
> python-ideas can't agree on a better syntax for python 4/5 does.
The only improvement I could hope for python 4/5 was to drop this
feature altogether. It's more trouble than it's worth; it saves a
couple of lines at the cost of error-proneness and head scratching
when reading other people's code and wondering "did he really mean
this or did he misunderstand what for/else does ?". People often
reject adding a do/while syntax with the argument that it can be
already expressed as a loop-and-a-half, and I bet do/while is at least
as common as for/else, probably more.
More information about the Python-ideas