Python has an identity crisis sometimes. It starts with the premise, from Guido’s prior work on ABC, to make a simple but easy to understand language.
But then turns around and cries out “one way to do it“, leaving the programmer perplexed as to how Guido van Rossum thought we should do things. For example, Guido hates tail calls, so recursion isn’t the one way to do it that he picked (note that his blog post and followups contain a large number of factual errors; read it as an opinion piece only).
During these fits, Python suffers itself to be a bondage and discipline language.
Apparently there is hope. One bit that causes me particular pain is that nested functions cannot rebind variables in the outer scope; only read from them. A case in point:
def f(): x = 1 def doubleIt(): x *= 2 # local variable 'x' referenced before assignment doubleIt(); doubleIt(); return x;
However, I was reading a piece on Factor, and it mentions that this restriction is lifted in Python 3.0. I’m still on 2.6 (the only differences I had been aware of were the somewhat arbitrary swapping of the ‘/’ and ” operators, and the insulting removal of map, filter, and reduce from Python 3.0). However, fixing this scoping rule, even if an extra keyword is needed, sure would be convenient for me.
Actually, there are a lot of improvements:
- Various APIs returns views instead of mutable list (copies).
- sorted is now built in. (I’ve had to write that myself so many times…)
- Apparently map and filter are still here (though he still went and put reduce all the way off in functools. I guess you can’t have it all -_-)
- Set literals, yay!
Now, if Guido would be so kind to add proper statement support to lambdas, I’ll switch ^_^. Oh, but Guido hates lambdas. Oh well, next time maybe.
— signed an ambivalent Python user