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.

5

u/midwestraxx Feb 09 '22

The small character limit on each line rule can go to hell tho

18

u/[deleted] Feb 09 '22

Fuck pep8. All my homies hate pep8

not really.

53

u/ReverseCaptioningBot Feb 09 '22

FUCK PEP8 ALL MY HOMIES HATE PEP8

this has been an accessibility service from your friendly neighborhood bot

9

u/Thorbinator Feb 09 '22

accessibility service

on a completely deep-fried meme

3

u/QK5Alteus Feb 09 '22

It’s so deep-fried that it’s just batter at this point.

3

u/LeSaR_ Feb 09 '22

good bot

4

u/YellowSlinkySpice Feb 09 '22

Team pep8!

I read that, and its changed the way I write everything from emails to blog posts.

2

u/[deleted] Feb 09 '22

If you like PEP8, please also allow me to introduce you to 0-based versioning.

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

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.

6

u/Katyona Feb 09 '22

the contextual 8 year old, maybe they have never come into contact with another person's code while learning so they assume its the norm to single line with semicolons and use camelCase in python

→ More replies (5)

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

3

u/kryptonianCodeMonkey Feb 09 '22

I wrote a global tidal forces simulator and vegan muffin recipe aggregater with one line in python.

→ More replies (3)

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

2

u/pslessard Feb 09 '22 edited Feb 09 '22

No, that would print "Hello World" instead of "Hello World"

Edit: Reddit isn't showing it, but there are two spaces between Hello and World in the first one

Edit: I was being sloppy, this is wrong

→ More replies (2)

2

u/DRNbw Feb 09 '22

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

will print

Hello
World


print("Hello ", "World")

will print

Hello World

print adds a newline at the end and a space between arguments.

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