semicolon at end of python's statements

  • Thread starter Mohsen Pahlevanzadeh
  • Start date
M

Mohsen Pahlevanzadeh

Dear all,

I'm C++ programmer and unfortunately put semicolon at end of my
statements in python.

Quesion:
What's really defferences between putting semicolon and don't put?

Yours,
Mohsen
 
R

Roy Smith

Mohsen Pahlevanzadeh said:
Dear all,

I'm C++ programmer and unfortunately put semicolon at end of my
statements in python.

Quesion:
What's really defferences between putting semicolon and don't put?

In theory, nothing. In practice, all the real Python programmers will
make fun of you.

Somewhat more seriously, every language has its own way of doing things.
There's the set of things the language allows you to do, and the
somewhat smaller set of things that have become accepted as the "proper"
way to do things in that language. For Python, putting semicolons at
the ends of statements falls into the first set but not the second.
 
C

Chris Angelico

In theory, nothing. In practice, all the real Python programmers will
make fun of you.

Somewhat more seriously, every language has its own way of doing things.
There's the set of things the language allows you to do, and the
somewhat smaller set of things that have become accepted as the "proper"
way to do things in that language. For Python, putting semicolons at
the ends of statements falls into the first set but not the second.

This is about Perl, but may be of interest.

http://www.perl.com/pub/2007/12/06/soto-11.html

One of his main points is that languages differ primarily in what they
force you to say - not what you're able to express. C forces you to
declare the ends of statements with semicolons. Python forces you to
be consistent with indentation. Smalltalk (if I have this correct)
forces you to put parentheses in expressions like a+b*c to declare
order of operations. German forces you to match das/die/der to the
noun it's referring to. Doing what a completely different programming
language forces you to do is like speaking with the wrong grammar
("Murdered in the bed we will be! One day we will in bed find
ourselves stone dead!"[1]); native speakers will understand you, but
it doesn't sound fluent.

ChrisA

[1] Mit der knife in der chess! Sun on the Stubble. Great book.
 
R

Roy Smith

Chris Angelico said:
This is about Perl, but may be of interest.

http://www.perl.com/pub/2007/12/06/soto-11.html

I got about halfway through, then raised an uncaught TLDNR Exception.
But I did like what he had to say about Tcl.

Tcl is under-appreciated. A few gigs back, I did a lot of work in Tcl.
We were writing a network management tool (long since subsumed into IBM
Tivoli via multiple corporate mergers and put out to pasture:
http://tinyurl.com/qxd4kw9).

The dev team consisted mostly of people who were networking subject
matter experts and not real programmers. Tcl turned out to be an
excellent tool to let the SME's express their networking knowledge in
executable form without having to learn C++, Java, or even Python.

Tcl is also ridiculously easy to embed. It's literally one line of C
code and you've got an embedded Tcl interpreter running.
 
S

Steven D'Aprano

Dear all,

I'm C++ programmer and unfortunately put semicolon at end of my
statements in python.

Quesion:
What's really defferences between putting semicolon and don't put?


It's about the same as writing this:


x = 1
pass
y = 2
pass
z = x**2 + y**2
pass
print z
pass



except you save three keystrokes per LOC.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,250
Latest member
Charlesreero

Latest Threads

Top