Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!newsfeed.xs4all.nl!newsfeed1.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.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'binary': 0.07; 'correct.': 0.07; 'parsed': 0.09; 'solution,': 0.09; 'terminated': 0.09; 'translate': 0.10; 'translation': 0.12; 'windows': 0.15; '24,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'mode,': 0.16; 'oddity': 0.16; 'underlying': 0.16; 'win,': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'module': 0.19; 'written': 0.21; 'code,': 0.22; 'header:In-Reply-To:1': 0.27; 'mode': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'code': 0.31; 'easier': 0.31; 'lines': 0.31; 'file': 0.32; 'run': 0.32; 'text': 0.33; 'open': 0.33; '(including': 0.33; 'problem': 0.35; 'subject:with': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'doing': 0.36; 'so,': 0.37; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; "you're": 0.61; 'you.': 0.62; 'show': 0.63; 'fact,': 0.69; 'jul': 0.74; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=t4b9z1bWs7vRWgbFeJm6U6w4KTBGFMeGfNTq1drAJ2s=; b=ljySdt/AyCLlaxpBSLOYBhpVKeegtL9wBc40Z96CFT5LEgm4cWWMd3PWAvBkesrrx1 3KTn+h/2/J2NfWNg/QygPf9Zyl+Khf0AP7kMHhwZxTt/FRRzMGnO1nRNquPdBhGYF7qG ymqUL8144mm9Ma/G1Ih75I7UWL7uPmQE9I8V4vuB3Hi7dijhSPn0o+93Yk3VhUpPFibP fXaihjfrdFDXf9EuTCb/yqH1icsuJdnpHW66j3N0xv9CIi8WzpNGBFwofeXC5ks/M58E fcQB+lAdc8pnhG0gy1qCB2ZlkNUe2yEeSipH4s9syPawfod9KqDWKgJ+9sg/DjyQvmR1 WnkQ== MIME-Version: 1.0 X-Received: by 10.58.249.236 with SMTP id yx12mr13388850vec.25.1374651566328; Wed, 24 Jul 2013 00:39:26 -0700 (PDT) In-Reply-To: <51EF7C0D.1040101@swing.be> References: <368qu85msgfhuk2j2s13qj0bqn4rkcint9@4ax.com> <51ED3CEB.1070706@gmail.com> <51eea057$0$29971$c3e8da3$5496439d@news.astraweb.com> <51EF7C0D.1040101@swing.be> Date: Wed, 24 Jul 2013 17:39:26 +1000 Subject: Re: Strange behaviour with os.linesep From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list 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: 23 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1374651928 news.xs4all.nl 15952 [2001:888:2000:d::a6]:34443 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:51121 On Wed, Jul 24, 2013 at 5:02 PM, Vincent Vande Vyvre wrote: > In fact, in my code, the original file is open in binary mode, the line > separator is translate to \n and it is parsed by the module tokenise. > > I'm not a Windows user but my code must be run also on Win, this is the > reason of the usage of os.linesep in writting. > > So, now I found the solution, just write the file in binary mode and now it > is correctly open with all the editors. > Sounds to me like the problem was double-translation - you in your code turned \n into \r\n, but then the file was written in text mode, doing the same translation, so your lines were terminated with \r\r\n. That would result in what you're seeing (including the oddity that some editors will show the file differently). You may find it easier to write the file in text mode and let the underlying system do the translation for you. Chances are that'll be correct. ChrisA