Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!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; 'output': 0.05; 'url:launchpad': 0.05; '-*-': 0.07; 'utf-8': 0.07; 'coding:': 0.09; 'lines:': 0.09; 'def': 0.12; "'w')": 0.16; 'from:addr:swing.be': 0.16; 'from:addr:vincent.vandevyvre': 0.16; 'from:name:vincent vande vyvre': 0.16; 'message-id:@swing.be': 0.16; 'oqapy': 0.16; 'paqager': 0.16; 'received:mobistar.be': 0.16; 'url:oqapy': 0.16; 'url:paqager': 0.16; 'url:qarte': 0.16; 'v.v.': 0.16; '\xe9crit': 0.16; 'header:User-Agent:1': 0.23; 'file.': 0.24; "i've": 0.25; 'changes,': 0.26; 'header:In-Reply- To:1': 0.27; 'skip:- 40': 0.29; 'lines': 0.31; 'txt': 0.31; 'skip:- 30': 0.32; 'subject:with': 0.35; 'but': 0.35; 'skip:o 20': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39 Date: Tue, 23 Jul 2013 15:26:07 +0200 From: Vincent Vande Vyvre User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130623 Thunderbird/17.0.7 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Strange behaviour with os.linesep References: <368qu85msgfhuk2j2s13qj0bqn4rkcint9@4ax.com> <51ED3CEB.1070706@gmail.com> <51EE6C15.5070701@swing.be> <51EE80CB.2010100@swing.be> In-Reply-To: <51EE80CB.2010100@swing.be> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit 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: 51 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1374585972 news.xs4all.nl 15990 [2001:888:2000:d::a6]:36453 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:51087 Le 23/07/2013 15:10, Vincent Vande Vyvre a écrit : > The '\n' are in the original file. > > I've tested these other versions: > > ------------------------------- > def write(): > strings = ['# -*- coding: utf-8 -*-\n', > 'import os\n', > 'import sys\n'] > with open('writetest.py', 'w') as outf: > txt = L_SEP.join([s.rstip() for s in strings]): > outf.write(txt) > ------------------------------ > > ------------------------------- > def write(): > strings = ['# -*- coding: utf-8 -*-', > 'import os', > 'import sys'] > with open('writetest.py', 'w') as outf: > txt = L_SEP.join( strings): > outf.write(txt) > ------------------------------ > > Las, no changes, always correctly displayed in MS bloc-notes but with > double line in other éditors. > Also with: ---------------------------------------- def count(): with open('c:\\Users\\Vincent\\writetest.py', 'r') as inf: lines = inf.readlines() for l in lines: print(l, len(l)) count() -------------------------------------- The output is: -------------------------------------- ('# -*- coding: utf-8 -*-\r\n', 25) ('import os\r\n', 11) ('import sys', 10) -- Vincent V.V. Oqapy . Qarte . PaQager