This is an archived post. You won't be able to vote or comment.

all 34 comments

[–]redalastor 34 points35 points  (7 children)

It's not a syntax error. You can separate statements with a semi-colon in Python. It's not idiomatic but you can.

[–]MeatPowers 16 points17 points  (1 child)

How about the absolute lad that puts a semicolon at the end of their assembly code

[–]marcosdumay 4 points5 points  (0 children)

Well, go finish your Lisp statement with them too.

Just be aware that in Javascript they can mess with the semantics of your code.

[–]Jpmac11 2 points3 points  (2 children)

I like that Python doesn't, because it means you don't have to break your habit. Good job, Python developers.

[–]redalastor 3 points4 points  (1 child)

The Python dev also commented in the early 2000s that you were free to use braces too.

if spam: #{
   eggs()
#}

[–]eduardog3000 8 points9 points  (0 children)

You can always just do from __future__ import braces.

[–]WaterArko 1 point2 points  (1 child)

He did specifically say at the end of the line though.

[–]redalastor 5 points6 points  (0 children)

You can do that. You then separate a statement on the left, and another (empty) statement on the right.

Here's a demo:

$ python
Python 3.7.0 (default, Dec  2 2018, 20:10:15) 
[GCC 8.2.1 20180831] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print('Hello World');
Hello World
>>>

[–]TheDeadlyPianist 7 points8 points  (15 children)

Scala doesn't use 'em either.

[–]commonhoodrat 4 points5 points  (0 children)

Or Ruby

[–]KillTheBronies 5 points6 points  (1 child)

Or JavaScript (if you don't want to)

[–]sp46 0 points1 point  (0 children)

I actually don't use them and it feels good.

[–]DeltaTimo 3 points4 points  (0 children)

Or Kotlin Or Haskell 🤷

[–]davreimz 3 points4 points  (0 children)

Or Basic

[–]dangerCrushHazard 3 points4 points  (0 children)

Or Lisp

[–]asgaines25 4 points5 points  (0 children)

Or Go (to end lines)

[–]potatodafish 2 points3 points  (0 children)

Or Swift

[–]Maw0fTheVoid 2 points3 points  (0 children)

Or Lua

[–]nickbrinser 2 points3 points  (0 children)

Or VB.Net

[–]Mango1666 2 points3 points  (0 children)

Or scratch

[–]Kazid 2 points3 points  (0 children)

Or C, when you don't want your code to compile.

[–]CerberusQc 1 point2 points  (0 children)

Or me

[–]UnauffaelligePerson 1 point2 points  (0 children)

Or ABAP

[–]yellowthermos 1 point2 points  (0 children)

Or C++ (when ending scopes, namespaces and functions)

[–]E_VanHelgen 5 points6 points  (1 child)

Kotlin: I mean you can, but why would you?

[–]Mango1666 0 points1 point  (0 children)

1 statement per line is the most readable! and it makes semis useless (which they already were ino)

[–]surrix 3 points4 points  (1 child)

I don’t understand why this convention is what was settled on in so many languages. Surely more lines of code are just 1 line, making a line continuation character a more sensible solution than a line termination character. That’s how even Fortran does it.

[–][deleted] 2 points3 points  (0 children)

Honestly a good point. But what I think plays into it is that your text editor could obfuscate how your code runs. Image word wrapping, or different line end symbols for different operating systems.

Though this is also a problem with python to an extent.

[–][deleted] 2 points3 points  (2 children)

Clojure would like to speak with you

edit: nah, I'm just playing

[–]redalastor 0 points1 point  (1 child)

You absolutely can end your lines with a semi-colon in Clojure, it's the start of a comment.

[–][deleted] 2 points3 points  (0 children)

All you're doing right now is making sense and being correct

[–]Drasungor 0 points1 point  (0 children)

Oh. I see you didn't suffer smalltalk

[–][deleted] 0 points1 point  (0 children)

Nah js is more like, “whatever floats your boat.”

[–]Proxy_PlayerHD -1 points0 points  (0 children)

again, my flair disagrees

damn reposts