3 Replies - 400 Views - Last Post: 01 November 2015 - 05:02 AM Rate Topic: -----

#1 O'Niel  Icon User is offline

  • D.I.C Regular

Reputation: 14
  • View blog
  • Posts: 389
  • Joined: 13-September 15

Acceptable to use semi-colons in Python?

Posted 31 October 2015 - 10:22 AM

Hello

I'm trying to get more into Python and make some nice things with it, but I was wondering:
I mostly program in curly brace programming languages (like C++ and PHP), and by that I really have the habit of ending my lines with a semi-colon (;), but in Python a semi-colon ain't really needed.

Still, I think it makes my code a lot more readable, so. Is it okay to also use semi-colons in Python? Do Python-programmers have problems with it? What if I'm going to work in team with other Python-programmers in the future? ...?

Thanks!

Is This A Good Question/Topic? 0
  • +

Replies To: Acceptable to use semi-colons in Python?

#2 Ryano121  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1461
  • View blog
  • Posts: 3,289
  • Joined: 30-January 11

Re: Acceptable to use semi-colons in Python?

Posted 31 October 2015 - 10:35 AM

I don't really see why you would want to use them in Python. The white space the interpreter requires should be enough to make your code readable enough - just have to get used to it.

Semi colons can be used to delimit statements on the same line, but again you shouldn't really need to do that all that often.

You will get a funny look from other Python programmers in your team if you start doing it as it doesn't follow the usual style guide.
Was This Post Helpful? 0
  • +
  • -

#3 baavgai  Icon User is online

  • Dreaming Coder
  • member icon


Reputation: 6996
  • View blog
  • Posts: 14,633
  • Joined: 16-October 07

Re: Acceptable to use semi-colons in Python?

Posted 31 October 2015 - 01:10 PM

Acceptable? In that it won't cause an error, sure.

However, how would you feel if you saw some source in your favorite curly language with stuff like this all over the place:
} /************************************************/



Sure, it won't bother the compiler, but WTF is wrong with this guy?

Every language has its own style and etiquette. To use a language most effectively, you should strive to observe the best accepted practices of any language you're working in, rather than pull in stuff you're comfortable with because you can. The most dramatic example would be C and C++, where C++ will let you do anything from C, which tends to result in crap C++.

Loose the semi colons. Free your inner Python.
Was This Post Helpful? 0
  • +
  • -

#4 O'Niel  Icon User is offline

  • D.I.C Regular

Reputation: 14
  • View blog
  • Posts: 389
  • Joined: 13-September 15

Re: Acceptable to use semi-colons in Python?

Posted 01 November 2015 - 05:02 AM

Okay, thanks for the replies!
I'll just try to make the switch each time when going from C++ to Python and the other way around (doesn't take more as an half hour to adapt though), and I'll use Ctrl + H / Ctrl + F at the end of my script to check for accidental semi-colons.

Thanks!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1