1

I sometimes see this ; symbol on tutorials and such, what does it indicate?

A-P
  • 497
  • 1
  • 4
  • 9

2 Answers2

5

Semi-colons are used in Python to separate statements in the same line.

print 1; print 2

Common use example:

import pdb; pdb.set_trace()
Reut Sharabani
  • 30,449
  • 6
  • 70
  • 88
  • 2
    And sometimes they are just remnants of code conversion between Python and languages which use the semicolons as line delimiter like C++, Java, etc. – wagnerpeer Dec 15 '14 at 07:43
  • Okay, just another follow up question, what if I am writing a really large dictionary, and I don't want all the keys to be on the same line because it makes it hard to read over, is there someway that I can denote that is continues to the next line? – A-P Dec 15 '14 at 07:44
  • 1
    @A-P , use a new line after the comma on each value. – Reut Sharabani Dec 15 '14 at 07:45
2

The semicolon can be used as a statement separator in Python, called stmt_list in the language reference, but its use is generally discouraged (PEP 8, compound statements). We prefer one statement per line.

Yann Vernier
  • 15,414
  • 2
  • 28
  • 26