[Python-Dev] Announcing PEP 3136

Guido van Rossum guido at python.org
Tue Sep 29 22:47:32 CEST 2009


On Tue, Sep 29, 2009 at 1:20 PM, Hatem Nassrat <hnassrat at gmail.com> wrote:
> Tue Jul 3 10:14:17 CEST 2007, Guido van Rossum wrote:
>> On 6/30/07, Matt Chisholm <matt-python at theory.org> wrote:
>> > I've created and submitted a new PEP proposing support for labels in
>> > Python's break and continue statements.  Georg Brandl has graciously
>> > added it to the PEP list as PEP 3136:
>> >
>> > http://www.python.org/dev/peps/pep-3136/
>>
>> I think this is a good summary of various proposals that have been
>> floated in the past, plus some new ones. As a PEP, it falls short
>> because it doesn't pick a solution but merely offers a large menu of
>> possible options. Also, there is nothing about implementation yet.
>>
>> However, I'm rejecting it on the basis that code so complicated to
>> require this feature is very rare. In most cases there are existing
>> work-arounds that produce clean code, for example using 'return'.
>
> I agree that this feature will only serve as a quick hack and in many
> cases it would be misused and ugly code will be the result. However,
> it seems that there are some shortcuts that have sneaked into python
> (I am a fairly new Python programmer, only since late 2.4, so don't
> shoot me). The specific one of which I speak about is:
>
> while_stmt ::=  "while" expression ":" suite
>                ["else" ":" suite]
>
> for_stmt ::=  "for" target_list "in" expression_list ":" suite
>              ["else" ":" suite]
>
> try1_stmt ::=  "try" ":" suite
>               ("except" [expression ["as" target]] ":" suite)+
>               ["else" ":" suite]
>               ["finally" ":" suite]
>
> All these else's seem like shortcuts to me. I did find a use for them,
> once I found out they existed, but I get butterflies whenever I do.

In English, butterflies are usually a good thing (they mean you'e in love).

These else clauses (assuming you're talking about that) have been in
the language pretty much forever. The combined except/finally clause
is newer, it was added because Java allows it and it was actually a
pretty common usage.

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-Dev mailing list