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


Groups > comp.lang.python > #45513

Re: How to write fast into a file in python?

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'that?': 0.05; 'convention.': 0.07; 'lines,': 0.07; 'subject:file': 0.07; 'happen.': 0.09; 'mess': 0.09; 'subject:into': 0.09; 'terminated': 0.09; 'subject:How': 0.10; 'windows': 0.15; '*any*': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'macs': 0.16; 'newlines': 0.16; 'subject:python': 0.16; 'apps': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'bit': 0.19; 'putting': 0.22; 'file.': 0.24; 'header:In-Reply-To:1': 0.27; 'unix': 0.29; 'dos': 0.30; 'mode': 0.30; 'message- id:@mail.gmail.com': 0.30; 'lines': 0.31; 'follows': 0.31; 'yes.': 0.31; 'file': 0.32; 'quite': 0.32; 'text': 0.33; 'open': 0.33; 'editor': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'accessing': 0.36; 'subject:?': 0.36; 'two': 0.37; 'convention': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'days': 0.60; 'mentioned': 0.61; 'characters,': 0.84; 'faster.': 0.84; 'notepad,': 0.84; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type:content-transfer-encoding; bh=9DlaPU3xytOSJgvpFSeEj0Xm5J5diRqsHnWk9XPUZ9I=; b=JRRJEgd7wcLV7wkIkE1aLUq+gUzAiTi1a9fkisoSO8tN/VfBEWhl27D22NBgW6f+k9 FLVcgRH2iVE85zY/4TrfN8/DvUtJXP7+N8H3txgiQphGhrJ7bFqtfCOur2pwpPCYGyDr znrsijTQT5iyY9+EuQqe2izdPyBZ8NHYEmdQM/byo4mQN4j0sOg8pu0n15DXyjwrFBh8 BTNQ82Ikn7Px2Jh9K3fGXQ7tGWfEr2dETXqgW1M0nI5CBx4XEFywr3sIedHkigIYDfBL zQbIEWfq6MTyVBcU6HlqR3Z/UU/mtJlOWrwwYPDs1Xd8ORD0EGioRAGWCmzjeiWQ/IFJ rxlA==
MIME-Version 1.0
X-Received by 10.52.164.163 with SMTP id yr3mr26678742vdb.76.1368887390386; Sat, 18 May 2013 07:29:50 -0700 (PDT)
In-Reply-To <CAA=1kxRK3F3_gYGEecRkHS33e5nEHa1KQqAK0BeODty0RqJH5A@mail.gmail.com>
References <e9dcd255-b892-40a0-ae6b-0995a61a270f@googlegroups.com> <87f9a3d4-427e-472f-bee7-9501ba842b36@googlegroups.com> <51961B73.2070401@davea.name> <mailman.1785.1368804103.3114.python-list@python.org> <51966d15$0$29997$c3e8da3$5496439d@news.astraweb.com> <BLU176-W2D076D16CF4457F289E40D7AC0@phx.gbl> <CAA=1kxRK3F3_gYGEecRkHS33e5nEHa1KQqAK0BeODty0RqJH5A@mail.gmail.com>
Date Sun, 19 May 2013 00:29:50 +1000
Subject Re: How to write fast into a file in python?
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
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.1805.1368887398.3114.python-list@python.org> (permalink)
Lines 27
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1368887398 news.xs4all.nl 16007 [2001:888:2000:d::a6]:46989
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:45513

Show key headers only | View raw


On Sat, May 18, 2013 at 5:49 PM, Fábio Santos <fabiosantosart@gmail.com> wrote:
> Putting len(os.linesep)'s value into a local variable will make accessing it
> quite a bit faster. But why would you want to do that?
>
> You mentioned "\n" translating to two lines, but this won't happen. Windows
> will not mess with what you write to your file. It's just that traditionally
> windows and windows programs use \r\n instead of just \n. I think it was for
> compatibility with os/2 or macintosh (I don't remember which), which used \r
> for newlines.
>
> You don't have to follow this convention. If you open a \n-separated file
> with *any* text editor other than notepad, your newlines will be okay.


Into two characters, not two lines, but yes. A file opened in text
mode on Windows will have its lines terminated with two characters.
(And it's old Macs that used to use \r. OS/2 follows the DOS
convention of \r\n, but again, many apps these days are happy with
Unix newlines there too.)

ChrisA

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


Thread

How to write fast into a file in python? lokeshkoppaka@gmail.com - 2013-05-16 20:20 -0700
  Re: How to write fast into a file in python? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-17 03:51 +0000
  Re: How to write fast into a file in python? lokeshkoppaka@gmail.com - 2013-05-16 21:35 -0700
    Re: How to write fast into a file in python? Dave Angel <davea@davea.name> - 2013-05-17 07:58 -0400
    RE: How to write fast into a file in python? Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-17 18:20 +0300
      Re: How to write fast into a file in python? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-17 16:42 +0000
        RE: How to write fast into a file in python? Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-17 20:25 +0300
      Re: How to write fast into a file in python? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-17 17:47 +0000
        RE: How to write fast into a file in python? Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-17 21:18 +0300
          Re: How to write fast into a file in python? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-18 04:01 +0000
            Re: How to write fast into a file in python? Chris Angelico <rosuav@gmail.com> - 2013-05-18 15:28 +1000
            Re: How to write fast into a file in python? 88888 Dihedral <dihedral88888@googlemail.com> - 2013-05-18 04:09 -0700
        RE: How to write fast into a file in python? Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-17 21:33 +0300
        RE: How to write fast into a file in python? Fábio Santos <fabiosantosart@gmail.com> - 2013-05-18 08:49 +0100
        Re: How to write fast into a file in python? Chris Angelico <rosuav@gmail.com> - 2013-05-19 00:29 +1000
        RE: How to write fast into a file in python? Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-18 20:00 +0300
          Re: How to write fast into a file in python? Tim Roberts <timr@probo.com> - 2013-05-19 19:04 -0700
        Re: How to write fast into a file in python? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-05-18 15:14 -0400
          Re: How to write fast into a file in python? Roy Smith <roy@panix.com> - 2013-05-18 15:37 -0400
          Re: How to write fast into a file in python? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-18 22:23 +0000
        Re: How to write fast into a file in python? Fábio Santos <fabiosantosart@gmail.com> - 2013-05-18 22:19 +0100
        Re: How to write fast into a file in python? Dave Angel <davea@davea.name> - 2013-05-18 22:41 -0400
        RE: How to write fast into a file in python? Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-19 06:53 +0300
        Re: How to write fast into a file in python? MRAB <python@mrabarnett.plus.com> - 2013-05-19 16:44 +0100
        RE: How to write fast into a file in python? Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-20 13:34 +0300
    Re: How to write fast into a file in python? Dan Stromberg <drsalists@gmail.com> - 2013-05-18 12:38 -0700
    RE: How to write fast into a file in python? Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-19 08:31 +0300
    RE: How to write fast into a file in python? Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-19 08:42 +0300
    Re: How to write fast into a file in python? Chris Angelico <rosuav@gmail.com> - 2013-05-19 19:21 +1000
    RE: How to write fast into a file in python? Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-19 12:41 +0300

csiph-web