Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #98606

Re: using binary in python

Path csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From Dennis Lee Bieber <wlfraed@ix.netcom.com>
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 <mailman.214.1447186467.16136.python-list@python.org> (permalink)
References <mailman.164.1447060794.16136.python-list@python.org> <HbGdndTOtKc3EdzLnZ2dnUU7-YnOydjZ@giganews.com>
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 <python-python-list@m.gmane.org>
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 <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Xref csiph.com comp.lang.python:98606

Show key headers only | View raw


On Mon, 9 Nov 2015 22:20:25 -0800, Larry Hudson via Python-list
<python-list@python.org> 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 <some> system defined means of marking
line endings. UNIX/Linux uses just a <LF> character; Windows uses the pair
<CR><LF>. TRS-DOS used just <CR> 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 (<LF>, 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 <end of
line><end of page><end of file> (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/

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

using binary in python kent nyberg <kent@z-sverige.nu> - 2015-11-08 16:27 -0500
  Re: using binary in python Jussi Piitulainen <harvesting@makes.email.invalid> - 2015-11-09 11:58 +0200
  Re: using binary in python Larry Hudson <orgnut@yahoo.com> - 2015-11-09 22:20 -0800
    Re: using binary in python Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-11-10 15:14 -0500
      Re: using binary in python mm0fmf <none@mailinator.com> - 2015-11-10 20:36 +0000
        Re: using binary in python Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-11-10 16:02 -0500
          OT: Re: using binary in python mm0fmf <none@mailinator.com> - 2015-11-10 22:17 +0000
        Re: using binary in python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-11-10 21:22 +0000
        Re: using binary in python Random832 <random832@fastmail.com> - 2015-11-10 19:03 -0500
        Re: using binary in python Random832 <random832@fastmail.com> - 2015-11-10 19:04 -0500
      Re: using binary in python Larry Hudson <orgnut@yahoo.com> - 2015-11-10 19:53 -0800
    Re: using binary in python Random832 <random832@fastmail.com> - 2015-11-10 15:44 -0500
    Re: using binary in python kent nyberg <kent@z-sverige.nu> - 2015-11-10 16:29 -0500
      Re: using binary in python Christian Gollwitzer <auriocus@gmx.de> - 2015-11-11 22:32 +0100
    Re: using binary in python Michael Torrie <torriem@gmail.com> - 2015-11-10 17:19 -0700

csiph-web