I'll at least agree I've met a lot of python snobs who say don't use the built in map/filter functions and things like that in favour of comprehensions, but that's hardly representative of the language.
And please. List comprehensions can be nested, just like every other language can be abused if you really want to try.
I'm sure there are immutable versions of those same data structures hidden somewhere in the standard library, but I haven't looked.
I did stumble upon pyrsistent (https://github.com/tobgu/pyrsistent) a while ago which does provide proper immutable (and persistent) data structures for python.
Do you mean something like a ternary operator? You can certainly do: x='foo' if condition else 'bar'.
In fact you can even do multiple assigments: (x,y) = ('foo1','foo2') if condition else ('foo3', 'foo4')
where 'Foo' may also be a function call.
>I think people feel like it's unpythonic and instead pollute the namespace with singleton classes that only have one method.
There's a few pycon talks on "a single method class should not be a class" but I'd say that's the single responsibility principle at its purest along with the community needing to move to more lightweight structures like namedtuples.
Documentation.
It's just a preference. Many tasks have more than one obvious way. But if you're asking to add a new feature, you should explain why it's worth the downside of adding yet another way to do it.
classes = (student.current_classes() for student in students)
good_grades = [c.grade for grade in classes if grade > 3.0]Why do you need everything to be an expression? Sure, a variable lookup takes a nanosecond, but that's a small price to pay for readability.
The fact that Python has an if expression and a lambda expression, but they were intentionally, not accidentally limited to one line should indicate there are some benefits to the trade-off.
For example: you can't assign the result of an "if" statement. Why? Because it's a SyntaxError, no real reason. There is even an "ifExp" in the language grammar, but that's only for inline ifs.
You can't have statements in lambdas, and map and filter are "unpythonic". Yet everybody feels like list comprehensions are the best thing after sliced bread, despite being the same thing.
Closures are also clunky: you can define another named function inside a function and call it afterwards, and you can use functools.partials from the stdlib, but I think people feel like it's unpythonic and instead pollute the namespace with singleton classes that only have one method.
Ultimately, to me it feels like this all hurts the composability of the idioms of the language. List comprehensions can be nested, but they feel clunky and they're in a syntactical wall garden. You can compose expressions, but not statements.