r/ProgrammerHumor • • Aug 26 '20

Python goes brrrr

Post image
59.2k Upvotes

789 comments sorted by

View all comments

Show parent comments

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.

13

u/ToPractise Aug 26 '20

Modern day Javascript

→ More replies (1)
→ 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.

0

u/[deleted] Aug 26 '20

[deleted]

5

u/BrandolynRed Aug 26 '20

I haven't kept up with additions to the language in a while. What does := do? It's a pain to google

0

u/[deleted] Aug 26 '20

[deleted]

4

u/BrandolynRed Aug 26 '20

Thanks, I can see why that's controversial. Tbh I'd prefer the rust style match pep.

0

u/[deleted] Aug 26 '20

[deleted]

3

u/BrandolynRed Aug 26 '20

A friend sent me this pep: https://www.python.org/dev/peps/pep-0622/

I just came to like pattern matching from haskell/rust etc.

→ More replies (1)

3

u/cowardly_lioness Aug 26 '20

It's often called the "walrus operator", which is easier to google than ":=" if you forget its exact function.

5

u/13steinj Aug 26 '20

But is := not pythonic? Even that's up to debate.

10

u/thirdegree Violet security clearance Aug 26 '20

It's a python operator, defined in pep, kinda by definition it is pythonic.

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

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.

16

u/Zyphite Aug 26 '20

I think technically it slows it down as it runs two statements, one being the statement before the semi colon and the other being a blank statement. This doesn't raise an error as Python allows blank statements.

35

u/EugeneJudo Aug 26 '20

In no world would it slow down the interpreter. Either they're stripped beforehand moving statements to their own lines so it doesn't have to deal with them, or it just treats it as a newline (the more likely case.)

4

u/[deleted] Aug 26 '20

Python is actually compiled before running

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

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

3

u/Nimeroni Aug 26 '20

The pep8 is a bit like a pedantic friend - sometime he has some good idea, but most of the time it's safe to ignore him.

→ More replies (1)
→ More replies (1)

0

u/[deleted] Aug 26 '20

[deleted]

137

u/rxwsh Aug 26 '20

Strict Indention is not a definite structure?

→ More replies (31)
→ More replies (7)
→ More replies (4)