Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2.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; 'string.': 0.05; "'',": 0.07; 'exists.': 0.07; 'none,': 0.07; 'builtin': 0.09; 'caller': 0.09; 'enabled,': 0.09; 'enabled.': 0.09; 'high- level': 0.09; 'newline': 0.09; 'os.path': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'terminated': 0.09; 'python': 0.11; 'jan': 0.12; 'translation': 0.12; 'windows': 0.15; '(it': 0.16; 'caller.': 0.16; 'entry:': 0.16; 'newlines': 0.16; 'portable': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'separator,': 0.16; 'applies': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'bit': 0.19; 'module': 0.19; 'translated': 0.19; 'written': 0.21; 'input': 0.22; 'aug': 0.22; 'header:User-Agent:1': 0.23; 'string,': 0.24; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'characters': 0.30; 'mode': 0.30; 'returned': 0.30; "i'm": 0.30; 'code': 0.31; 'lines': 0.31; 'coded': 0.31; 'default,': 0.31; 'universal': 0.31; 'supposed': 0.32; 'text': 0.33; 'maybe': 0.34; 'convert': 0.35; 'but': 0.35; '14,': 0.36; 'controls': 0.36; 'being': 0.38; 'follows:': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'major': 0.40; 'how': 0.40; 'skip:u 10': 0.60; 'full': 0.61; 'received:173': 0.61; 'email addr:gmail.com': 0.63; 'details,': 0.68; 'default': 0.69; 'legal': 0.71; 'ending': 0.78; '(here': 0.84; 'extreme,': 0.84; 'received:fios.verizon.net': 0.84; 'streams': 0.84; '2013,': 0.91; 'directly.': 0.95 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: .split() Qeustion Date: Wed, 14 Aug 2013 15:45:10 -0400 References: <94f8428f-50b9-4ccd-95a0-6eeafda0fe18@googlegroups.com> <1376499950.3355.9802231.6A03F40D@webmail.messagingengine.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-173-75-251-66.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 In-Reply-To: <1376499950.3355.9802231.6A03F40D@webmail.messagingengine.com> 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: 45 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1376509523 news.xs4all.nl 15906 [2001:888:2000:d::a6]:42065 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:52532 On 8/14/2013 1:05 PM, random832@fastmail.us wrote: > On Wed, Aug 14, 2013, at 10:32, wxjmfauth@gmail.com wrote: >> I'm always and still be suprised by the number of hard coded >> '\n' one can find in Python code when the portable (here >> win) >> >>>>> os.linesep >> '\r\n' >> >> exists. > Because high-level code isn't supposed to use the os module directly. This is a bit extreme, but definitely true for os.linesep and *much* of os other than os.path and maybe os.environ. > Text-mode streams automatically convert newlines you write to them. By default, to \n when reading files;, \n to os.linesep when writing. Windows is the only major OS for which os.linesep is not \n. The full details, from the builtin 'open' entry: " newline controls how universal newlines mode works (it only applies to text mode). It can be None, '', '\n', '\r', and '\r\n'. It works as follows: When reading input from the stream, if newline is None, universal newlines mode is enabled. Lines in the input can end in '\n', '\r', or '\r\n', and these are translated into '\n' before being returned to the caller. If it is '', universal newlines mode is enabled, but line endings are returned to the caller untranslated. If it has any of the other legal values, input lines are only terminated by the given string, and the line ending is returned to the caller untranslated. When writing output to the stream, if newline is None, any '\n' characters written are translated to the system default line separator, os.linesep. If newline is '' or '\n', no translation takes place. If newline is any of the other legal values, any '\n' characters written are translated to the given string. " -- Terry Jan Reedy