Path: csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail From: Dennis Lee Bieber Newsgroups: comp.lang.python Subject: Re: using binary in python Date: Tue, 10 Nov 2015 15:14:20 -0500 Organization: IISS Elusive Unicorn Lines: 32 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de WCf8mcAzLIksy9BdK53QNg4WJZ/lry6BpSX+9FyiLu5Q== 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; 'binary': 0.05; 'character,': 0.07; 'defines': 0.07; 'difference,': 0.07; 'file)': 0.07; 'lines.': 0.07; 'newline': 0.07; "'w',": 0.09; 'defined.': 0.09; 'differently.': 0.09; 'marking': 0.09; 'message- id:@4ax.com': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:using': 0.09; 'subject:python': 0.14; 'explicitly': 0.15; "'r'": 0.16; 'bits).': 0.16; 'delimiters': 0.16; 'opened.': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'segment': 0.16; 'uses,': 0.16; 'byte': 0.18; 'url:home': 0.18; 'language': 0.19; 'windows': 0.20; '2015': 0.20; 'strict': 0.22; 'suppose': 0.22; 'unix/linux': 0.22; 'defined': 0.23; 'mon,': 0.24; 'header:X-Complaints-To:1': 0.26; 'data,': 0.27; 'values': 0.28; 'feature,': 0.29; 'larry': 0.29; 'handled': 0.29; 'another': 0.32; 'returned': 0.32; 'consist': 0.33; 'file': 0.34; 'could': 0.35; 'text': 0.35; 'formats': 0.35; 'nov': 0.35; 'returning': 0.35; 'but': 0.36; 'there': 0.36; 'lines': 0.36; '(and': 0.36; 'data.': 0.36; 'mode': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'being': 0.37; 'operating': 0.37; 'received:org': 0.37; 'charset:us-ascii': 0.37; 'difference': 0.38; 'files': 0.38; 'end': 0.39; 'means': 0.39; 'goes': 0.39; 'data': 0.39; 'whatever': 0.39; 'does': 0.39; 'to:addr:python.org': 0.40; 'some': 0.40; 'easy': 0.60; 'course': 0.62; 'ending': 0.63; 'between': 0.65; 'python-list': 0.66; 'records': 0.70; 'treat': 0.72; 'obvious': 0.76; '>of': 0.84; 'controllable': 0.84; 'detecting': 0.84; 'dennis': 0.91; 'received:108': 0.93 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: 108.68.178.61 X-Newsreader: Forte Agent 6.00/32.1186 X-No-Archive: YES X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:98606 On Mon, 9 Nov 2015 22:20:25 -0800, Larry Hudson via Python-list declaimed the following: >Of course it can. The only difference a text file and a binary file is the way it's opened. >Text files are opened with 'r' or 'w', while binary files are opened with 'rb' or 'wb'. Being >different modes, the reading/writing is handled differently. One obvious difference, the lines >of a text file are marked by ending them with a newline character, so it's easy to read/write >the text line-by-line. But the data in a binary file is completely arbitrary and is much To be strict -- a text file has system defined means of marking line endings. UNIX/Linux uses just a character; Windows uses the pair . TRS-DOS used just for end of line. Some operating systems may have used count-delimited formats (and then there is the VMS FORTRAN segmented records with start and end segment bits). Whatever the system uses, a text file can be read by "lines", the system detecting the break between lines. A file opened in binary mode does not have "lines", and if the system uses in-band delimeters (, et al) those delimiters are returned as just another byte of data. (I suppose a count-based system could treat the length as either in-band, returning it as data, or out-of-band, stripping the count values while returning the rest). The Ada language defines the end of Text file to consist of (yes, the language defines end-of-page as a controllable feature, and explicitly states that all three must be at the end of a file) BUT then goes on to state that the nature of the delimiters is implementation defined. -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/