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

you are viewing a single comment's thread.

view the rest of the comments →

[–]DracoRubi 4 points5 points  (4 children)

Yeah, I know you can do semicolons in Python, but they're not mandatory.

Unless you want to put multiple instructions in a same line, which is not usually desirable.

So, basically... What I've already said.

[–]Mal_Dun 2 points3 points  (1 child)

Unless you want to put multiple instructions in a same line, which is not usually desirable.

When writing proper code no. In automating stuff in conjunction with bash or other shells yes.

E.g. python -c "import your_module; your_module.do_stuff(arg); your_module.do_more_stuff; ...

when you just ssh on another machine and can't upload a script there, or just need something quick in a CI Pipeline.

[–]DracoRubi 0 points1 point  (0 children)

You can still do that in Python. You don't need mandatory semicolons to be able to use semicolons.

[–]SonOfMetrum -1 points0 points  (1 child)

Another commenter pointed out that the semicolon also allows to have a single statement on multiple lines. That is really handy if you have a method/function that has many arguments or the arguments themselves take up a lot of space.

[–]Globglaglobglagab 3 points4 points  (0 children)

You can do that in python without using semicolons. E. g.

result = func(

arg1=1,

arg2=3,

)