News for hackers. Stuff that matters.
Re:Python's super considered harmful by cturner on Tuesday December 28, 2010 @01:07PM (#2046164)

    > did I miss something?
In your examples you're binding or rebinding to vars in the current scope. The issue is rebinding vars outside of the current scope.

Perhaps this code demonstates what I'm getting at.

    def my_function():
        a = 1
        def modify_a():
            a = 2
        modify_a()
        print a # prints 1
        #
        b = [1]
        def modify_b():
            b = 2
        modify_b()
        print b[0] # prints 1
        #
        c = [1]
        def modify_c():
            c[0] = 2
        modify_c()
        print c[0] # prints 2

    my_function()
Re:Python's super considered harmful by masklinn on Tuesday December 28, 2010 @01:17PM (#2046197)
This is clearer, but it has absolutely nothing to do with `for` loops (which is why your statement utterly confused me) and everything to do with Python's broken scoping in general: Python 2 gives no writing access to lexical scopes between global and local (Python 3 added a new keyword, `nonlocal`, which is used in the same manner as `global` to set a binding as writable in a parent scope).