Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3.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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'explicitly': 0.05; '"""': 0.07; 'attribute': 0.07; 'binary': 0.07; 'append': 0.09; 'newline': 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; 'thus,': 0.09; 'python': 0.11; '2.7': 0.14; 'windows': 0.15; "'b'": 0.16; "'r'.": 0.16; 'message-id:@4ax.com': 0.16; 'mode,': 0.16; 'newlines': 0.16; 'open()': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'supplying': 0.16; 'tuple': 0.16; 'file,': 0.19; 'seems': 0.21; '2.x': 0.24; 'url:home': 0.24; 'values': 0.27; 'header:X -Complaints-To:1': 0.27; 'external': 0.29; 'character': 0.29; 'unix': 0.29; 'characters': 0.30; 'mode': 0.30; 'lines': 0.31; 'usually': 0.31; "d'aprano": 0.31; 'default,': 0.31; 'steven': 0.31; 'universal': 0.31; 'file': 0.32; 'text': 0.33; 'open': 0.33; 'subject:with': 0.35; 'convert': 0.35; 'objects': 0.35; 'but': 0.35; 'charset:us-ascii': 0.36; 'should': 0.36; 'received:76': 0.38; 'convention': 0.38; 'to:addr:python-list': 0.38; 'little': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'called': 0.40; 'is.': 0.60; 'introduced': 0.61; 'back': 0.62; 'different': 0.65; 'between': 0.67; 'containing': 0.69; 'default': 0.69; 'jul': 0.74; 'opens': 0.91; 'silent': 0.95; '2013': 0.98 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dennis Lee Bieber Subject: Re: Strange behaviour with os.linesep Date: Tue, 23 Jul 2013 19:51:58 -0400 Organization: IISS Elusive Unicorn References: <51ED3CEB.1070706@gmail.com> <51eea057$0$29971$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: adsl-76-249-27-96.dsl.klmzmi.sbcglobal.net X-Newsreader: Forte Agent 6.00/32.1186 X-No-Archive: YES 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: 42 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1374623529 news.xs4all.nl 15875 [2001:888:2000:d::a6]:59234 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:51111 On 23 Jul 2013 15:25:12 GMT, Steven D'Aprano declaimed the following: >I don't think it is. Behaviour is a little different between Python 2 and >3, but by default, Python uses "Universal Newlines". When you open a file Oh? When did that change come about... So far as I recall, Python 2.x introduced a "universal newline" mode character for the open() function. IE, one had to explicitly ask for universal mode during the open. Python 2.7 help file """ open(filename[, mode[, bufsize]]) to 'r'. The default is to use text mode, which may convert '\n' characters to a platform-specific representation on writing and back on reading. Thus, when opening a binary file, you should append 'b' to the mode value to open the file in binary mode, which will improve portability. (Appending 'b' is In addition to the standard fopen() values mode may be 'U' or 'rU'. Python is usually built with universal newline support; supplying 'U' opens the file as a text file, but lines may be terminated by any of the following: the Unix end-of-line convention '\n', the Macintosh convention '\r', or the Windows convention '\r\n'. All of these external representations are seen as '\n' by the Python program. If Python is built without universal newline support a mode with 'U' is the same as normal text mode. Note that file objects so opened also have an attribute called newlines which has a value of None (if no newlines have yet been seen), '\n', '\r', '\r\n', or a tuple containing all the newline types seen. """ Seems to be silent with regards to /writing/; suspect writing will use the system convention unless using "wb"/"ab" to force binary mode. -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/