Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #53356
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.002 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'algorithm': 0.04; 'advance': 0.07; 'string': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'trailing': 0.09; 'useless': 0.09; 'python': 0.11; 'illustrate': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'suggestion.': 0.16; 'wrote:': 0.18; 'cheap': 0.19; 'header:User-Agent:1': 0.23; 'header:X-Complaints-To:1': 0.27; 'testing': 0.29; 'instruction': 0.29; "doesn't": 0.30; 'compared': 0.30; 'cases': 0.33; 'actual': 0.34; 'problem': 0.35; 'but': 0.35; '(we': 0.36; 'false': 0.36; 'should': 0.36; 'skip:- 20': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'space': 0.40; 'solve': 0.60; 'occur': 0.65; 'clearer': 0.84; 'otten': 0.84; 'subject:space': 0.84 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Peter Otten <__peter__@web.de> |
| Subject | Re: print function and unwanted trailing space |
| Date | Sat, 31 Aug 2013 15:59:21 +0200 |
| Organization | None |
| References | <5221a693$0$2059$426a74cc@news.free.fr> <mailman.405.1377938644.19984.python-list@python.org> <5221b68b$0$2280$426a74cc@news.free.fr> <mailman.406.1377945101.19984.python-list@python.org> <5221f0af$0$2412$426a34cc@news.free.fr> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="UTF-8" |
| Content-Transfer-Encoding | 8Bit |
| X-Gmane-NNTP-Posting-Host | p508488bf.dip0.t-ipconnect.de |
| User-Agent | KNode/4.7.3 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.412.1377957573.19984.python-list@python.org> (permalink) |
| Lines | 37 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1377957573 news.xs4all.nl 15920 [2001:888:2000:d::a6]:55161 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:53356 |
Show key headers only | View raw
candide wrote: > Le 31/08/2013 12:31, Peter Otten a écrit : > > softspace = False > > for i in range(5): > > if softspace: > > print(end=" ") > > print(i, end="") > > softspace = True > > print() > > > The if instruction imposes useless testing (we know in advance the > problem to occur at the very end of the loop) and useless writing > (writing ''). To make it crystal clear, the above was to illustrate the algorithm used in Python 2, not a suggestion. Python 2 uses that "useless testing" -- which is cheap compared to actual I/O. > The following is clearer > > # ------------------------- > n=5 > for i in range(n-1): > print(i, end=' ') > print(n-1) > # ------------------------- > > > but doesn't solve all the cases (imagine a string or an iterator). I still think you should live with a trailing space or go with my actual suggestion print(*range(5))
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
print function and unwanted trailing space candide <candide@free.invalid> - 2013-08-31 10:17 +0200
Re: print function and unwanted trailing space Andreas Perstinger <andipersti@gmail.com> - 2013-08-31 10:43 +0200
Re: print function and unwanted trailing space candide <candide@free.invalid> - 2013-08-31 11:25 +0200
Re: print function and unwanted trailing space Peter Otten <__peter__@web.de> - 2013-08-31 12:31 +0200
Re: print function and unwanted trailing space candide <candide@free.invalid> - 2013-08-31 15:33 +0200
Re: print function and unwanted trailing space Peter Otten <__peter__@web.de> - 2013-08-31 15:59 +0200
Re: print function and unwanted trailing space candide <candide@free.invalid> - 2013-08-31 17:58 +0200
Re: print function and unwanted trailing space Chris Angelico <rosuav@gmail.com> - 2013-09-01 01:30 +1000
Re: print function and unwanted trailing space Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-08-31 16:43 +0100
Re: print function and unwanted trailing space Chris Angelico <rosuav@gmail.com> - 2013-09-01 08:08 +1000
Re: print function and unwanted trailing space Joshua Landau <joshua@landau.ws> - 2013-09-01 00:15 +0100
Re: print function and unwanted trailing space Terry Reedy <tjreedy@udel.edu> - 2013-08-31 19:57 -0400
Re: print function and unwanted trailing space candide <candide@free.invalid> - 2013-08-31 17:51 +0200
Re: print function and unwanted trailing space Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-08-31 11:16 +0000
Re: print function and unwanted trailing space Peter Otten <__peter__@web.de> - 2013-08-31 14:27 +0200
Re: print function and unwanted trailing space Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-08-31 13:37 +0100
Re: print function and unwanted trailing space candide <candide@free.invalid> - 2013-08-31 14:59 +0200
Re: print function and unwanted trailing space Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-08-31 15:18 +0000
Re: print function and unwanted trailing space Ned Batchelder <ned@nedbatchelder.com> - 2013-08-31 07:24 -0400
Re: print function and unwanted trailing space candide <candide@free.invalid> - 2013-08-31 15:51 +0200
Re: print function and unwanted trailing space Wayne Werner <wayne@waynewerner.com> - 2013-09-11 06:36 -0500
Re: print function and unwanted trailing space Albert Hopkins <marduk@letterboxes.org> - 2013-09-12 15:25 -0400
csiph-web