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


Groups > comp.lang.python > #98606

Re: using binary in python

From Dennis Lee Bieber <wlfraed@ix.netcom.com>
Newsgroups comp.lang.python
Subject Re: using binary in python
Date 2015-11-10 15:14 -0500
Organization IISS Elusive Unicorn
Message-ID <mailman.214.1447186467.16136.python-list@python.org> (permalink)
References <mailman.164.1447060794.16136.python-list@python.org> <HbGdndTOtKc3EdzLnZ2dnUU7-YnOydjZ@giganews.com>

Show all headers | 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