Earlier quoted context omitted.
in my experience, the python ecosystem is a mess. yes, there are lots of libraries, but that is just one part of the ecosystem. for one, everyone uses a different distribution, whether it's anaconda, python(x,y), or just the default python install. this creates a lot of fragmentation, and it's hard to come into a project and fix the mess that's been created. then there's the 2.x vs 3.x issue that is still a problem.…
You're right, it is a mess. Don't get me wrong, there's a huge number of packages available and a lot of them are really quality and I have used the language a lot , but good gosh is the packaging a deployment a fucking disaster. Environments are a 3rd party bolt on, that relies on hacking around with environment variables. There's no distinction between dev dependencies and actual, application dependencies. The pack…
Stop writing lambda expressions in Python
141–150 of 202 posts
Re: Stop writing lambda expressions in Python
#142Earlier quoted context omitted.
Guido seemingly has a strong distaste for functional ideas, so anything that comes from that paradigm ends up getting an almost half-assed implementation. See also: map and filter being the only 2 other functions implemented and both of them being less performant than their imperative equivalents; outright denial of any attempt at TCO because "Guido doesn't like recursion".
> outright denial of any attempt at TCO because "Guido doesn't like recursion". No, don’t ignore problems of TCO by saying “guys don’t like functional programimg”. Guido cleary states why he doesn’t like it: [1]. Even though TCO is one of the ES6 standard, TCO also is largely denied by JS implementors (Firefox, Chrome, and Edge devs) because of the similar reasons. As a result, Safari is the only browser that support…
We will sometimes optimize for TCO, that issue is that we can’t guarantee it just yet.
Re: Stop writing lambda expressions in Python
#143Earlier quoted context omitted.
Van Rossum started to work on Python in 1989 and released the first version in 1991. Python is modern in the sense of being still very well alive but it's deeply rooted in the 80s, and it shows with all those double underscore __magic functions__, the self argument in methods (the way we were doing object oriented programming in C, without the ++) and others. Compared to JavaScript it didn't evolve it's syntax much.…
`self` is about being explicit with parameters. Rust does the same thing and that's a more "modern" language. The `__magic__` is about avoiding naming conflicts while still being explicit. It's a choice between magic or reserving a lot of names.
Re: Stop writing lambda expressions in Python
#144Earlier quoted context omitted.
Why does it need that, though? What's wrong with just naming the function?
It's not so much naming the function, but that doing so moves it outside the flow of the logic it is participating in. Especially when it's going to reference local context that is particularly confusing. There are definitely times when extracting out a function and naming it is the right thing to do. But there are an equal number of times when keeping all the local context together is better. It's probably hard to a…
Re: Stop writing lambda expressions in Python
#145Earlier quoted context omitted.
Why does it need that, though? What's wrong with just naming the function?
There's real readability and clarity to positioning an anonymous function right at the point in the code that it will be used. When you name and define a function some other place and use it elsewhere, you have increased the overall complexity. What is this named function? Where is it used? Is it accessed by other bits of code? Should it be? All these questions come up when you see a named function. It is in fact les…
It makes no sense at all to break up the wonderful conceptual flow of functional components like map, fmap, filters, folds, monadic operations, with sudden harsh definition of a function that takes your brain out of the context of what was flowing and into the context of what is the function.
I want to see something like
val someStat = myData.groupBy(thingExtractor)
.foldLeft(baselineValue)(statAccumulator)
I want the mental task of grokking thingExtractor, baselineValue or statAccumulator to be a wholly separate task from seeing what flows into the calculation of someStat. I want to look elsewhere in the code for those things, kind of like expanding or collapsing a block of text: keep it out of mind when it doesn’t matter.Re: Stop writing lambda expressions in Python
#146Earlier quoted context omitted.
Hmmmm. I don't see the relationship between async/await and fat arrows. Can you explain more about how async/await obviates the need for fat arrows?
Just async is callback based. You don't need callbacks with async/await. No callbacks, no need for fat arrow.
Re: Stop writing lambda expressions in Python
#147Earlier quoted context omitted.
It also doesn't have tail-recursion or macros. There are many who also regard that lack as a deep design flaw. There never was a goal in Python development to support all programming paradigms. How do you distinguish between "design flaw" and "different design goal than what you want"?
I think, it was an example of intentional hostile design (say, see this video https://www.youtube.com/watch?v=NWZLB8CyPbM for what I mean). All, seemingly for the sake of that "only-one-way-to-do-things" goal. EDIT: (Van Rossum's own explanation of why he thinks lambda's design is okay: https://www.artima.com/weblogs/viewpost.jsp?thread=147358 )
The phrase, by the way, is "one obvious way".
Re: Stop writing lambda expressions in Python
#148Earlier quoted context omitted.
Why does it need that, though? What's wrong with just naming the function?
It's not so much naming the function, but that doing so moves it outside the flow of the logic it is participating in. Especially when it's going to reference local context that is particularly confusing. There are definitely times when extracting out a function and naming it is the right thing to do. But there are an equal number of times when keeping all the local context together is better. It's probably hard to a…
Re: Stop writing lambda expressions in Python
#149Earlier quoted context omitted.
Why does it need that, though? What's wrong with just naming the function?
There's real readability and clarity to positioning an anonymous function right at the point in the code that it will be used. When you name and define a function some other place and use it elsewhere, you have increased the overall complexity. What is this named function? Where is it used? Is it accessed by other bits of code? Should it be? All these questions come up when you see a named function. It is in fact les…
Re: Stop writing lambda expressions in Python
#150Earlier quoted context omitted.
Python has a convention for "private" functions, which is to prepend "_" to the name. > It's hard to make a strong case just in words, but once you really understand the power of the fat arrow syntax for anonymous inline functions then you use it more and more and it becomes second nature and the programs you write have a completely different style, oriented towards neatly positioned inline anonymous functions everyw…
Private functions do not restrict the usage of that function to one point in the code. There's a world of difference between a coding convention - essentially a comment to say "please don't access this function from outside the current class" versus it simply being impossible to do so. And the "private" convention does not say "don't use this function at any other point except one", it says "please don't access this…