Project

General

Profile

Idea #11770

Updated by Tom Morris almost 7 years ago

Implementation should match that of the Python 3 file open method as described at: https://docs.python.org/release/3.2/library/functions.html#open 

 ??newline controls how universal newlines works (it only applies https://docs.python.org/2/library/functions.html#open 

 includiing support for the @newlines@ field. 

 ??In addition to text mode). It can the standard fopen() values mode may be None, '', '\n', '\r', and '\r\n'. It works as follows: 

 On input, if newline 'U' or 'rU'. Python is None, usually built with universal newlines mode is enabled. Lines in support; supplying 'U' opens the input can end in 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 '\r\n', and the Windows convention '\r\n'. All of these external representations are translated into seen as '\n' before being returned to by the caller. Python program. If it Python is '', built without universal newline newlines support a mode with 'U' is enabled, but line endings are returned to the caller untranslated. If it same as normal text mode. Note that file objects so opened also have an attribute called newlines which has any a value of None (if no newlines have yet been seen), '\n', '\r', '\r\n', or a tuple containing all the other legal values, input lines are only terminated by the given string, and the line ending is returned to the caller untranslated. 
 On output, if newline is None, any '\n' characters written are translated to the system default line separator, os.linesep. If newline is '', no translation takes place. If newline is any of the other legal values, any '\n' characters written are translated to the given string. 
 ?? types seen.?? 

 Note that the Python 2 method of specifying a mode of 'rU' is now deprecated. 

Back