I've heard list comprehension is more optimized that map, reduce etc due to the way it is implemented in Python. Something to do work map, reduce being function calls
As a long time Java developer, I so very much appreciate Streams. It's so much more readable to say "I have a stream of Xs; convert them to Ys, take out the lowercase ones, add them to a Set, and return it" than "create a new Set. Now iterate through all the Xs. Declare a variable of type Y. Now set it to the conversion result of X. If Y is lowercase, add it to the set. Now return the set."
And that's a simple example. Once you start dealing with Lists of Lists, things go off the rails so quickly and the nesting becomes so ugly.
That’s interesting to read, as a beginner I find them very confusing and think it’s much simpler to do one thing after another, especially once it comes to looking for bugs.
Yeah, I can understand that. Streams add another layer of abstraction that requires understanding the core behaviors first. Streams are basically shortcuts for longer blocks of code, and they're easier to compose but can be harder to debug if you're not certain about what's happening under the hood. They provide incredible flexibility and conciseness, which is why they're so useful.
Just wait until you start getting into RX. Even once you get the hang of Java Streams, RX is going to make you so confused and frustrated that you're going to want to give up, but sticking with it is so worth it in the end. I'd recommend waiting a few years before even looking into RX though.
Semicolons are a pep8 violation (and I'm guessing every python style guide follows the same rule), so python does sorta care about semicolons - just not enough to stop execution
I support braces for structure but semicolons are just junk in 99% of cases, because I don't put multiple statements on same line in 99+% of cases. Newline is much better separator than semicolon
I feel the same way. I need my braces and semicolons. Even in something like c++, not using braces for a 1 line if statement feels wrong and messes with my brain
413
u/[deleted] Aug 26 '20
Started learning python and thats my favourite thing after no ; thingy