2

So I know in Python it's considered bad form to end statements with a ; when not doing compound statements. And the use of such statements are considered bad form as well.

I also understand the reasons to stick with the KISS mentality an that since they aren't required it doesn't make sense to keep them. But since at work I spend all my time with programming languages that require it, and only play with Python in my spare time, putting semicolons on the end of every statement is a rather ingrained habit.

And it's just going to be me looking at my code anyway so if it's just a style convention I'm not going to worry about it. But if there's an actual reason to avoid it I'd like to know.

Does it actually hurt to use them or is it just bad style? I mean, does it cause any performance or other issues or is it just a readability thing?

Why I think this question is different than the one where the guy was asking if they need to put them in, is that I wanted to know if it slowed down the running of the program, or caused it to use more memory or anything other than simply "making it harder for a person to read the code" that wasn't addressed in that topic.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Kit Ramos
  • 1,533
  • 1
  • 15
  • 32
  • Bad style (flake8 flags this as a [E703](http://pep8.readthedocs.io/en/latest/intro.html#error-codes)) as this is non-standard. However these type of questions can sometimes get quite opinionated so not really suitable for SO. – metatoaster Aug 31 '16 at 04:27
  • 1
    Possible duplicate of [When is semicolon use in Python considered "good" or "acceptable"?](http://stackoverflow.com/questions/19365508/when-is-semicolon-use-in-python-considered-good-or-acceptable) – metatoaster Aug 31 '16 at 04:28
  • I saw that post, but I don't think it's a duplicate, a corollary maybie. but in that one they ask if there's any harm in leaving them out. in mine I'm asking is there any harm in leaving them in. – Kit Ramos Aug 31 '16 at 04:32
  • 1
    IME, it's better to _not_ make code from different languages look alike. Different languages require different mindsets, and giving each one a distinct visual style acts as a cue to get your mind into the right mode for the current language you're working on. – PM 2Ring Aug 31 '16 at 05:26
  • I get your point PM 2Ring, but that strays in the idea of code style. and That's not what the question was about, it wasn't on readability or mindset or any sort of style. but rather if there's any runtime difference between one two sets of code with the only difference being the inclusion of the semicolon's in one of them. So any answers about why the person reading the code might treat the two different aren't relevant to this question only if the computer would is. – Kit Ramos Sep 01 '16 at 23:13

1 Answers1

3

It's purely a style thing. It's not going to hurt performance, and the worst weird edge case you'll run into is that this:

do_whatever();;
# two of these^

is a syntax error.

user2357112
  • 260,549
  • 28
  • 431
  • 505