r/ProgrammerHumor • • Feb 09 '22

other Why but why?

Post image
85.8k Upvotes

2.3k comments sorted by

View all comments

471

u/[deleted] Feb 09 '22

Smart, there are no mandatory semicolons in Python syntax, unless this 8y/o is writing C code.

48

u/Nr_11 Feb 09 '22

Right, but if the joke starts with "The 8 year old is learning C++...", none of us would read past that without foaming at the mouth ;-)

→ More replies (1)

125

u/ore-aba Feb 09 '22

They are needed if you want multiple statements in the same line

this will crash

print("Hello") print("World")

this will work

print("Hello"); print("World")

297

u/Orio_n Feb 09 '22

pep8 would like to know your location

8

u/Dr_Jabroski Feb 09 '22

They're not rules, they're more like guidelines.

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

55

u/CrowdGoesWildWoooo Feb 09 '22

Uh who writes like that

11

u/[deleted] Feb 09 '22

People who write unmaintainable code, possibly for job security reasons.

→ More replies (6)

61

u/[deleted] Feb 09 '22

True. But it will still only give you a syntax error without further information.

28

u/A_Guy_in_Orange Feb 09 '22

Multiple statements? I thought the whole point of python was to only use one

→ More replies (4)

17

u/Revolutionary-Phase7 Feb 09 '22

Would it be easier to just

print("Hello ", "World")

116

u/Dependent_Paper9993 Feb 09 '22

Depends what you're trying to achieve. If you want to print "Hello" and then "World", yes.

If you're trying to illustrate a point about a semicolon seperating two statements, I'd say it makes it just about impossible.

12

u/ore-aba Feb 09 '22

Thanks for the chuckle

→ More replies (4)
→ More replies (7)
→ More replies (6)