Why does ";" exist?

There’s something I’ve been ignoring for quite some time, but I decided to find out today.
Why does Python support the “;” symbol for terminating statements?
And since users clearly don’t use it, wouldn’t it be best to remove it?
I’m just asking to find out and I’m not against the use of this symbol.

I use it all the time. Mostly like so:

python3 -c 'import math; print(math.sin(10))'

One-liners are useful for quick evaluation from a shell.


It probably exists because of the influence of C and Pascal on Python’s
creator, Guido van Rossum. If he were designing Python today, who knows
if he would allow semicolons or not?

Personally, I find semicolons handy in the interactive shell and when
running Python snippets directly from the command line.

One liners in the shell are really useful when supporting users in some contexts. You can ask people to run a python -c ... line to show various package versions, the location of site.USER_BASE, and other important info.

1 Like

I documented several use cases for semicolons, including python -c, here: Does Python support semicolons? - Adam Johnson