Re: isPrime works but UnBoundLocalError when mapping on list

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Fredrik Lundh

    Re: isPrime works but UnBoundLocalError when mapping on list

    Andreas Tawn wrote:
    I never knew that and I can't find reference to it in the docs.
    the for-in loop does ordinary assignments in the current scope:



    "Each item in turn is assigned to the target list using the
    standard rules for assignments, and then the suite is executed."

    somewhat simplified, "for vars in expression: code" is equivalent to
    inlining:

    _ = iter(expression )
    while 1:
    try:
    vars = _.next()
    except StopIteration:
    break
    else:
    body

    where "_" is an internal variable.

    </F>

Working...