Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #53199 > unrolled thread

Re: semicolon at end of python's statements

Started byTim Chase <python.list@tim.thechases.com>
First post2013-08-28 19:35 -0500
Last post2013-08-28 19:35 -0500
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: semicolon at end of python's statements Tim Chase <python.list@tim.thechases.com> - 2013-08-28 19:35 -0500

#53199 — Re: semicolon at end of python's statements

FromTim Chase <python.list@tim.thechases.com>
Date2013-08-28 19:35 -0500
SubjectRe: semicolon at end of python's statements
Message-ID<mailman.334.1377736483.19984.python-list@python.org>
On 2013-08-29 04:48, Mohsen Pahlevanzadeh wrote:
> 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?

From a technical standpoint, nothing (see below).  From a "readability
on the part of other programmers" standpoint, it's bad practice.  So
if you're coding for yourself, do whichever makes you happy.  If you
want to interact with other Python developers and don't want to make
them grumpy, remove them.

-tkc



>>> def with_semis():
...     print 1;
...     print 2;
...     print 3;
... 
>>> def without_semis():
...     print 1
...     print 2
...     print 3
... 
>>> import dis
>>> dis.dis(with_semis)
  2           0 LOAD_CONST               1 (1)
              3 PRINT_ITEM          
              4 PRINT_NEWLINE       

  3           5 LOAD_CONST               2 (2)
              8 PRINT_ITEM          
              9 PRINT_NEWLINE       

  4          10 LOAD_CONST               3 (3)
             13 PRINT_ITEM          
             14 PRINT_NEWLINE       
             15 LOAD_CONST               0 (None)
             18 RETURN_VALUE        
>>> dis.dis(without_semis)
  2           0 LOAD_CONST               1 (1)
              3 PRINT_ITEM          
              4 PRINT_NEWLINE       

  3           5 LOAD_CONST               2 (2)
              8 PRINT_ITEM          
              9 PRINT_NEWLINE       

  4          10 LOAD_CONST               3 (3)
             13 PRINT_ITEM          
             14 PRINT_NEWLINE       
             15 LOAD_CONST               0 (None)
             18 RETURN_VALUE        

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web