Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Why we hate python

Name: Anonymous 2007-09-09 12:36 ID:q4NZHhgp

I hate python because everything looks like:


do something
           do something
           do something
                    do something
                    do something
           do something


I MEAN WHAT THE FUCK??? THERES LIKE THINGS YOU CAN USE TO SEPERATE BLOCKS OF CODE LIKE {[()]} PYTHON WTF?

Name: Anonymous 2007-09-10 15:38 ID:weUDNfFg

>>38
= rebinds a variable in the local scope, instead of modifying its contents which is what you wanted. When Python sees "x = 2" in g, it'll make x a local variable, shadowing f's x, and producing an error when you read it before assignment in print x+1.

I know this sucks, but at least it makes sense: variables are all references to objects, numbers and strings are immutable, and the assignment statement rebinds a variable; it doesn't change its contents. If you want to modify an object, use a mutable object such as a list or a dictionary.

In Python 3.0 (beta coming soon), you'll be able to work the way you want, by declaring x an "outer" variable with the outer keyword. You'd just insert:
outer x
between def g(): and print x+1.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List