by lmm · 9y ago · 0 comments
asyncio is new; python3 porting is happening. It seems unfair to complain that no real improvements are being made and also complain that these new things are immature.
reduce being pushed behind an import is stupid, but it's only one import.
lambda is fine, if you're writing in functional style you're using expressions for everything anyway. And you will probably be more persuasive if you can make your points less offensively.
For "bag of data" classes look at attrs.
(All that said, having found Scala I don't miss Python at all. (Except when writing a desktop GUI - PyQt was really nice))
Yes, attrs seems like a good solution for plain-old-data classes. https://attrs.readthedocs.io/en/stable/
No, I /really would/ like to be able to write:
foo.on_click(lambda: x += 1)
The language not supporting this (when most others do) is just silly.
Mutation in lambdas is not compatible with your complaint about "inadequate support for high-level functional programming", as it goes against the principles of FP.
You can't do that in Haskell either, and any FP purist would blanch at a statement like that.
What about us FP pragmatists? Also in some domains I'd argue being a FP purist is the most pragmatic option.
Obviously you've never met State and/or lens then.
Yes, you can do it -- and no, I never said it should follow pure FP principles.
foo.on_click(lambda:x func(x, whatever)) lambda x: func(x, whatever)
In fact, if x is an object that stores a mutable numeric cell, you could even do a mutating: lambda x: x.add(1)
Mutation isn't prohibited in Python lambdas, statements (including assignments, which are statements rather than expressions in Python), however, are.Mutating variables in a lambda is something abhorred in many functional languages.
foo.on_click(partial(q.append, foo))
The nice thing about ``append`` is it's atomic (for builtins).I guess this is another "simplification" along with the magic scoping model (I want perl's my/ES6's let damnit sulk) ...
I love namedtuple, but this seems like a better implementation for light-weight classes.