r/ProgrammerHumor • • Aug 26 '20

Python goes brrrr

Post image
59.2k Upvotes

789 comments sorted by

View all comments

413

u/[deleted] Aug 26 '20

Started learning python and thats my favourite thing after no ; thingy

115

u/ProbablyInnacurate Aug 26 '20

I love comprehensions.

50

u/axlee Aug 26 '20

I prefer lambdas + map/reduce/filter/etc, usually easier to understand with a quick look

27

u/marmoshet Aug 26 '20

Functional programming gang rise up

→ More replies (4)

15

u/ProbablyInnacurate Aug 26 '20

Oh yeah, defs. I get stuck making them complex, unreadable and un-pythonic because it's fun.

7

u/Ghos3t Aug 26 '20

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

→ More replies (5)

26

u/Mr_Redstoner Aug 26 '20

As a (mainly) Java programmer, a lot of my Streams would be comprehensions in Python.

16

u/mpa92643 Aug 26 '20

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.

7

u/Dizzfizz Aug 26 '20

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.

9

u/AnotherUpsetFrench Aug 26 '20

You will get used to it, I promise, especially when you will start to gain more time and less headaches.

8

u/mpa92643 Aug 26 '20

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.

→ More replies (1)
→ More replies (9)
→ More replies (2)
→ More replies (7)

0

u/[deleted] Aug 26 '20

[deleted]

403

u/zdaga9999 Aug 26 '20

Well you can put semicolons, python doesn't care.

117

u/groostwoost Aug 26 '20

TIL this

53

u/lightgiver Aug 26 '20

The difference is your code won't go poof if you miss a semicolon in python

8

u/XuBoooo Aug 26 '20

It will go poof if you forget indentation.

→ More replies (2)
→ More replies (2)

0

u/[deleted] Aug 26 '20

[deleted]

36

u/DarthRoach Aug 26 '20

But your friends will bully you for not being pythonic if you do that.

→ More replies (13)

23

u/zdaga9999 Aug 26 '20

I know that, but it doesn't care if you put it at the end and then hit enter.

→ More replies (6)

16

u/[deleted] Aug 26 '20

Everyone at your organization will hate you though. Gotta follow internal style standards.

7

u/infecthead Aug 26 '20

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

→ More replies (3)
→ More replies (44)

57

u/AngelLeliel Aug 26 '20

Python has its own special semicolon. It's called line break. That's it. Take it or leave it.

→ More replies (5)

37

u/marco89nish Aug 26 '20

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

35

u/MysticTheMeeM Aug 26 '20

But it also makes it hard to have one statement over multiple lines.

→ More replies (10)
→ More replies (3)

7

u/DonutDonutt Aug 26 '20

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

→ More replies (2)
→ More replies (42)
→ More replies (4)