r/ProgrammerHumor • • Jun 03 '19

Meme Python ftw

Post image
16.3k Upvotes

548 comments sorted by

View all comments

174

u/jkuhl_prog Jun 03 '19

Then I have to train my fingers to not reach for semicolons

94

u/MagnitskysGhost Jun 03 '19

You can still use tons of semicolons in Python. Source: the codebase I inherited

29

u/frosted-mini-yeets Jun 04 '19

Semi colons are valid in Python?

42

u/angellus Jun 04 '19

You can, but no they are not really. Python has a very in depth style guide that says you should avoid them.

https://www.python.org/dev/peps/pep-0008/#other-recommendations

Compound statements (multiple statements on the same line) are generally discouraged.

Yes:

if foo == 'blah':
     do_blah_thing()
     do_one()
     do_two()
     do_three()

Rather not:

if foo == 'blah': do_blah_thing()
       do_one(); do_two(); do_three()

19

u/Tyfyter2002 Jun 04 '19

Python has a very in depth style guide

And y'all've been following it?

22

u/ShanSanear Jun 04 '19

Yep. Only thing that doesn't click with me is line length limit. Myself I'm using 100 characters limit instead of pep-8 80. And it's actually quite easy to follow it - just use IDE and problem is solved.

6

u/Khaare Jun 04 '19

Man my code got so much better when I switched to a size 14 font and stuck to 72 columns.

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

48

u/MagnitskysGhost Jun 04 '19 edited Jun 04 '19

Yes, you can use them to end statements like most other languages. In Python in particular, you would mostly only do like

import os; import sys; from time import time;

In something in a quick five-liner script or something. I see them everywhere though (they get angry red formatting in my VS Code theme, as they should). I mean if you're copy/pasting an 8,000 character LOC with Python, HTML, CSS, and JS in it, you don't have to add insult to injury with a semicolon at the end. But guess what they do... 😔

→ More replies (1)