Python is simple and easy because it takes everything you know from other languages and systems and makes those things simple and easy and pleasant to do. I've even seen Python used as a kind of runnable pseudocode for projects that would eventually be written in other object-oriented Algol-based imperative languages, which is a testament to how well it distills those concepts down and makes programming simple. But it is not "readable in English." It is readable in pseudo-Algol.
When I was helping @limedaring learn Python, I'd read source with her and explain what it does. Quite often I'd feel somewhat embarrassed when explaining what a line does by verbatim reading what it says.
"for user in users: ..."
"if user.is_admin: ..."
It was especially nice that the topic of "what code block does this condition apply to?" did not even occur to either of us. The indentation-based blocks made it completely organic. (Try explaining Bash to someone and when to use do/done, if/else/fi, case/esac.)
But sure, things get weird with decorators and generators and other advanced features.
Better function syntax? What's wrong with python's function syntax and how does it relate to decorators?
Python does have anonymous functions, though they are limited: You can have only 1 expression, you can't have statements, and you can't have local variables. The reasoning is lambdas should be used for small operations; for everything else, named functions should be used.
The reasoning behind lambdas is arguable, but it still doesn't explain how it affects decorators.
Consider:
def memoize(fn):
from functools import wraps
@wraps(fn)
def memoized_fn(*args):
if not memoized_fn.cache.has_key(args):
memoized_fn.cache[args] = fn(*args)
return memoized_fn.cache[args]
memoized_fn.cache = {}
return memoized_fn
@memoize
def fib(n):
if n < 2: return n
return fib(n-1) + fib(n-2)
print fib(100)
What would a better function syntax and anonymous functions do so that memoize decorator won't be a thing? fib=memoize(function...)
So the @ shortcut for: def fib():
...
fib=memoize(fib)
wouldn't be necessary to 'clean up' the decoration of the function. @memoize
def fib:
pass
fib = memoize(function ...) has unnecessary nesting, and @memoize is cleaner IMO.I am curious - do you find @memoize confusing? Personally for me and anyone I have talked to, @memoize is vanilla - the confusing part is the decorator itself, especially one that takes arguments; that coupled with the fact that classes(which override __call__) and functions are both used as decorators.
Also there is plenty of Python code that is not particularly readable even superficially, particularly convoluted uses of list comprehension come to mind.
And I don't think 'consistency' is one of python's main qualities, when even in the stdlib there are plenty of very different naming styles. (Yes, this is improving in Python 3, but has been a big issue for a very long time.)
Python encourages code which is readable in English and reasonably brief. Having readability, consistency, and the "principle of least surprise" as primary language and community principles ultimately saves developers time and makes them more efficient.
And the maturing of PyPy is incredibly exciting.