Loading ...
Sorry, an error occurred while loading the content.

Initial proposal: New for statement

Expand Messages
  • gzeljko
    Define new looping construct with semantic: for item from generator: (generator = any object callable without parameters) as: new_for_stmt: for
    Message 1 of 2 , Feb 28, 2001
    View Source
    • 0 Attachment
      Define new looping construct

      with semantic:

      for item from generator:

      (generator = any object callable without parameters)

      as:

      new_for_stmt: "for" target_list "from" expression_list ":" suite
      ["else" ":" suite]

      The expression list is evaluated once; it should yield a object
      callable without parameters.
      Then callable object is called forever. On each call returned values
      are assigned to the target list using the standard rules for
      assignments, and then the suite is executed. Callable object can
      break loop raiseing predefined exception.
      .... (as for .. in)


      Alternative:

      Clearly overlay for..in with this semantic.

      So for..in meaning going to be:

      if expresion_list_yield_sequence:
      do_what's_god_expect
      elif expresion_list_yield_generator:
      try_this_slowly
      else:
      error_but_who_knows

      Motivation:
      Support for iterators, but this is open ...

      ly-y'rs-gzeljko
    • Guido van Rossum
      No, no, no. No new statements. --Guido van Rossum (home page: http://www.python.org/~guido/)
      Message 2 of 2 , Feb 28, 2001
      View Source
      • 0 Attachment
        No, no, no. No new statements.

        --Guido van Rossum (home page: http://www.python.org/~guido/)
      Your message has been successfully submitted and would be delivered to recipients shortly.