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


Groups > comp.lang.python > #53378

Re: print function and unwanted trailing space

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <joshua.landau.ws@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.019
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; 'else:': 0.03; 'string': 0.09; 'try:': 0.09; 'val': 0.09; 'cc:addr:python-list': 0.11; 'benjamin': 0.16; 'iterables': 0.16; 'simpler,': 0.16; 'unsafe': 0.16; 'sender:addr:gmail.com': 0.17; 'wrote:': 0.18; '>>>': 0.22; 'cc:addr:python.org': 0.22; 'error': 0.23; 'cc:2**0': 0.24; 'pass': 0.26; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'chris': 0.29; 'am,': 0.29; 'raise': 0.29; "doesn't": 0.30; 'message-id:@mail.gmail.com': 0.30; 'went': 0.31; '>>>>': 0.31; 'sep': 0.31; 'cases': 0.33; 'maybe': 0.34; 'except': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'version:': 0.36; 'words,': 0.36; 'similar': 0.36; 'solve': 0.60; 'august': 0.61; "you'll": 0.62; 'more': 0.64; 'to:addr:gmail.com': 0.65; 'oscar': 0.84; 'subject:space': 0.84; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=c1Ep1AkFerhfcB7FfFX2EOE5ZHljumYeUmswC5G9fYA=; b=x2MXXNND5HFpX7a7wlDejJbqIeuxxBtnzWDE5a8+g4NUy1H+r+o7QkCDJaygwJFJ6I /KNVaqKKUU1v6Cp7Ma0PNV8b9aNL2pQmRCKqaBXBFiRZW3OwRonhk22TrbYuxnLZJs9o YOa/AHpdVYSOXMFpth64SXzsNeJh73Xocvr8+w0JQDgQ9YGXWYRmPMIMSTOIgenqYTcX 5ZgJWXUnEnRuFM1RP6kFN8sR2wUG368XAlpDXrkf8ElOGI5+CWtjAvICUH4H/PyMcu+L 7il4pEwbKiVCV8/XmgmoppROiGvC3lDRsBxcKhagKSk/R8m3i8kI2kmgWw06MdZOAikx 42rw==
X-Received by 10.152.87.143 with SMTP id ay15mr14375551lab.2.1377990962749; Sat, 31 Aug 2013 16:16:02 -0700 (PDT)
MIME-Version 1.0
Sender joshua.landau.ws@gmail.com
In-Reply-To <CAPTjJmqraDbbt_SQGyT3pxjKEn79DHjeuLS+HY1-w4S06_j_jg@mail.gmail.com>
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> <CAPTjJmpkJbEMdhHO9n5uERS4umD_hi1hx5RHDzkv6iM68VXoSw@mail.gmail.com> <CAHVvXxSZ_Pm939idyA5R5ayj3daCJ2Lfw679jGRfiYDWpMiakQ@mail.gmail.com> <CAPTjJmqraDbbt_SQGyT3pxjKEn79DHjeuLS+HY1-w4S06_j_jg@mail.gmail.com>
From Joshua Landau <joshua@landau.ws>
Date Sun, 1 Sep 2013 00:15:22 +0100
X-Google-Sender-Auth 7XC5PefIroUila-1x1Crx0ay1nk
Subject Re: print function and unwanted trailing space
To Chris Angelico <rosuav@gmail.com>
Content-Type text/plain; charset=UTF-8
Cc python-list <python-list@python.org>
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.424.1377990970.19984.python-list@python.org> (permalink)
Lines 34
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1377990970 news.xs4all.nl 15864 [2001:888:2000:d::a6]:37411
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:53378

Show key headers only | View raw


On 31 August 2013 23:08, Chris Angelico <rosuav@gmail.com> wrote:
> On Sun, Sep 1, 2013 at 1:43 AM, Oscar Benjamin
> <oscar.j.benjamin@gmail.com> wrote:
>> On 31 August 2013 16:30, Chris Angelico <rosuav@gmail.com> wrote:
>>>>
>>>> but doesn't solve all the cases (imagine a string or an iterator).
>>>
>>> Similar but maybe simpler, and copes with more arbitrary iterables:
>>>
>>> it=iter(range(5))
>>> print(next(it), end='')
>>> for i in it:
>>>     print('',i, end='')
>>
>> If you want to work with arbitrary iterables then you'll want
>>
>> it = iter(iterable)
>> try:
>>     val = next(it)
>> except StopIteration:
>>     pass  # Or raise or something?
>> else:
>>     print(val, end='')
>> for i in it:
>>     print('', i, end='')
>
> I went with this version:
>
> except StopIteration:
>     raise
>
> In other words, if it's going to bomb, let it bomb :)

I think the point is that StopIteration is an unsafe error to raise.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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