Is this PEP-able? fwhile

Discussion in 'Python' started by jimjhb@aol.com, Jun 25, 2013.

  1. Guest


    > Syntax:
    > fwhile X in ListY and conditionZ:


    There is precedent in Algol 68:

    for i from 0 to n while safe(i) do .. od

    which would also make a python proposal that needs no new key words:

    for i in range(n) while safe(i): ..

    The benefit of the syntax would be to concentrate the code
    expressing the domain of the loop rather than have it in separate locations..

    Not a big win in my opinion.

    Neil

    Neil,

    I disagree. The problem IMO is that python 'for's are a different kind of 'for' in that they have no explicit indexing and no explicit range test; just a list which has elements drawn from it. This is amazingly
    powerful and concise. Unfortunately, the "breaks are just gotos" communityoften ruins this conciseness by going to 'while' or itertools (or worse) to avoid adding a break to a 'for' which needs to be terminated early.

    I think suggestions like yours and Fabio's are good ones. If 'for' has an 'else', why not a 'while'?

    FWIW, I can sympathize with the 'no breaks or continues' notion, at least largely so. That said, I have used gotos sparingly in C. The problem is that applying the no-breaks notion to the python 'for' is problematic becauseas I said earlier, the python 'for' is a special kind of 'for'. Maybe Guido needs to be seen in public hugging a break statement..... :)
    , Jun 25, 2013
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    94
    Chris Angelico
    Jun 26, 2013
  2. Ian Kelly

    Re: Is this PEP-able? fwhile

    Ian Kelly, Jun 24, 2013, in forum: Python
    Replies:
    7
    Views:
    104
  3. Ian Kelly

    Re: Is this PEP-able? fwhile

    Ian Kelly, Jun 24, 2013, in forum: Python
    Replies:
    0
    Views:
    91
    Ian Kelly
    Jun 24, 2013
  4. Fábio Santos

    Re: Is this PEP-able? fwhile

    Fábio Santos, Jun 24, 2013, in forum: Python
    Replies:
    0
    Views:
    96
    Fábio Santos
    Jun 24, 2013
  5. Joshua Landau

    Re: Is this PEP-able? fwhile

    Joshua Landau, Jun 24, 2013, in forum: Python
    Replies:
    0
    Views:
    93
    Joshua Landau
    Jun 24, 2013
Loading...

Share This Page