Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'lines,': 0.05; 'default.': 0.07; 'newline': 0.07; 'suppress': 0.07; 'trailing': 0.07; 'subject:question': 0.08; 'python': 0.09; 'assumed': 0.09; 'complaining': 0.09; 'parameter.': 0.09; 'sep': 0.09; 'windows,': 0.09; 'cc:addr:python-list': 0.10; '"b"': 0.16; "'b'": 0.16; '``print``': 0.16; 'comma': 0.16; 'comma.': 0.16; 'outputs': 0.16; 'wrote:': 0.17; 'odd': 0.17; 'string,': 0.17; '>>>': 0.18; 'followed': 0.20; 'written': 0.20; 'cc:2**0': 0.23; 'statement': 0.23; 'cc:no real name:2**0': 0.24; 'least': 0.25; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; 'prevent': 0.27; 'end,': 0.29; 'mode.': 0.29; 'character': 0.29; "i'm": 0.29; 'usually': 0.30; 'ends': 0.30; 'keyword': 0.30; 'mode': 0.30; 'file': 0.32; 'print': 0.32; 'done': 0.34; 'pm,': 0.35; 'too.': 0.35; 'but': 0.36; 'subject:: ': 0.38; 'takes': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'help': 0.40; 'end': 0.40; 'stuck': 0.65; 'header:Reply- To:1': 0.68; 'received:74.208': 0.71; 'reply-to:no real name:2**0': 0.72; '(print': 0.84; 'received:74.208.4.194': 0.84; 'angel': 0.93 Date: Sun, 02 Sep 2012 16:15:42 -0400 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0 MIME-Version: 1.0 To: gwhite Subject: Re: newbie ``print`` question References: <23e8e5c4-fb47-4753-b936-e1d546702387@pz10g2000pbb.googlegroups.com> <09a119ef-4374-4740-808f-69f8df555f40@f4g2000pbq.googlegroups.com> In-Reply-To: <09a119ef-4374-4740-808f-69f8df555f40@f4g2000pbq.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:cNHElyPP3o6VzECFYDFr6FxlQSqd5cI2zZvNVFBrYdO /DRN9WnCqySa37aihlExuAsdyhvzIoMLLYeprLLocCXYfJuHhh +kdeB+AH9/reioqoMJZCZDeBuHUcZLTxM0uGsKEWjKDKvII+M1 EUI/KdjLH9+5jcrFVOtSZqA5/4xm5XRnimn+GRrMYO2PEd8qdg VH9AjuK4Zzsdzwj4pzuat9WC+4bL5UfFihOvGRNYl8JhOS88d1 oWG5j4moLnblmdD8D/A4KlqDaQH3lvYimqhtBT7SRTXNUDZ0mn DB8tJzhCFLt6k63d7IGv9P2biExeB9DlxZRi+7+76j7IiNYMg= = Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: d@davea.name List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 35 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1346616968 news.xs4all.nl 6930 [2001:888:2000:d::a6]:32797 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:28311 On 09/02/2012 03:50 PM, gwhite wrote: > On Sep 2, 12:43 pm, Dave Angel wrote: >> On 09/02/2012 03:34 PM, gwhite wrote: >> >>> >>> btw, I also thought the default "add a CR LF" to the end was odd too. >>> But at least that one had a simple way out. >> But it (print on Python 2.x) doesn't, unless you're stuck on Windows. >> And even then, you can prevent it by using a 'b' in the mode. > Yes, I'm using windows. What is "'b' in the mode?" The help for > print says: > > A ``'\n'`` character is written at the end, unless the ``print`` > statement ends with a comma. This is the only action if the statement > contains just the keyword ``print``. > > So I followed with a comma to stop the default CR LF insertion. > You're correct; the best way to suppress the newline at the end of print is to use the trailing comma. But since print is for lines, it usually is a good default. If you don't want to get any extra characters, just use write(). It takes a string, and outputs exactly what it's given. I assumed you were complaining about the conversion of newline to carriage-return-newline, which is done by default on Windows, and can be suppressed by opening the file with "b" as the mode parameter. -- DaveA