Re: using binary in python

2015-11-11 Thread Christian Gollwitzer
Am 10.11.15 um 22:29 schrieb kent nyberg: On Mon, Nov 09, 2015 at 10:20:25PM -0800, Larry Hudson via Python-list wrote: Your questions are somewhat difficult to answer because you misunderstand binary. The key is that EVERYTHING in a computer is binary. There are NO EXCEPTIONS, it's all binary

Re: using binary in python

2015-11-10 Thread Larry Hudson via Python-list
On 11/10/2015 12:14 PM, Dennis Lee Bieber wrote: 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

Re: using binary in python

2015-11-10 Thread Michael Torrie
On 11/10/2015 02:29 PM, kent nyberg wrote: > On Mon, Nov 09, 2015 at 10:20:25PM -0800, Larry Hudson via Python-list wrote: >> Your questions are somewhat difficult to answer because you misunderstand >> binary. The key is that EVERYTHING in a computer is binary. There are NO >> EXCEPTIONS, it's a

Re: using binary in python

2015-11-10 Thread Random832
Dennis Lee Bieber writes: > Given that a dram is 1/8 of a "fluid ounce" that leads to the > conclusion that a "wee dram" is based on US standard fluid once, 29.6 ml > vs British standard fluid ounce... 28.4 ml It's our _pints_ that are smaller than yours, not our ounces. -- https://mai

Re: using binary in python

2015-11-10 Thread Random832
Dennis Lee Bieber writes: > > Given that a dram is 1/8 of a "fluid ounce" that leads to the > conclusion that a "wee dram" is based on US standard fluid once, 29.6 ml > vs British standard fluid ounce... 28.4 ml It's our _pints_ that are smaller than yours, not our ounces. -- https://m

OT: Re: using binary in python

2015-11-10 Thread mm0fmf via Python-list
On 10/11/2015 21:02, Dennis Lee Bieber wrote: On Tue, 10 Nov 2015 20:36:52 +, mm0fmf via Python-list declaimed the following: On 10/11/2015 20:14, Dennis Lee Bieber wrote: The Ada language defines the end of Text file to consist of It is 15 years this month since I last worked in place

Re: using binary in python

2015-11-10 Thread kent nyberg
On Mon, Nov 09, 2015 at 10:20:25PM -0800, Larry Hudson via Python-list wrote: > Your questions are somewhat difficult to answer because you misunderstand > binary. The key is that EVERYTHING in a computer is binary. There are NO > EXCEPTIONS, it's all binary ALL the time. The difference comes ab

Re: using binary in python

2015-11-10 Thread Mark Lawrence
On 10/11/2015 20:36, mm0fmf via Python-list wrote: On 10/11/2015 20:14, Dennis Lee Bieber wrote: The Ada language defines the end of Text file to consist of It is 15 years this month since I last worked in place that used Ada. I think that calls for a wee dram to celebrate ;-) Followed by a

Re: using binary in python

2015-11-10 Thread Random832
Dennis Lee Bieber writes: > 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

Re: using binary in python

2015-11-10 Thread mm0fmf via Python-list
On 10/11/2015 20:14, Dennis Lee Bieber wrote: The Ada language defines the end of Text file to consist of It is 15 years this month since I last worked in place that used Ada. I think that calls for a wee dram to celebrate ;-) -- https://mail.python.org/mailman/listinfo/python-list

Re: using binary in python

2015-11-09 Thread Larry Hudson via Python-list
Your questions are somewhat difficult to answer because you misunderstand binary. The key is that EVERYTHING in a computer is binary. There are NO EXCEPTIONS, it's all binary ALL the time. The difference comes about in how this binary data is displayed and manipulated. I want to emphasize, A

Re: using binary in python

2015-11-09 Thread Marko Rauhamaa
Chris Angelico : > On Tue, Nov 10, 2015 at 2:46 AM, Marko Rauhamaa wrote: >> I program for Linux. I use different programming languages, but the >> target is Linux. The systems I build and deal with consist of >> different components written in different programming languages but >> they all foll

Re: using binary in python

2015-11-09 Thread Chris Angelico
On Tue, Nov 10, 2015 at 2:46 AM, Marko Rauhamaa wrote: > I program for Linux. I use different programming languages, but the > target is Linux. The systems I build and deal with consist of different > components written in different programming languages but they all > follow Linux-y conventions t

Re: using binary in python

2015-11-09 Thread Marko Rauhamaa
Chris Angelico : > On Tue, Nov 10, 2015 at 1:32 AM, Marko Rauhamaa wrote: >> Yes, and lists and dicts and ints and objects and all. No problem >> there. >> >> However, when filenames and sys.stdin deal with text, things are >> getting iffy. > > So where do you mark the boundary between the human

Re: using binary in python

2015-11-09 Thread Chris Angelico
On Tue, Nov 10, 2015 at 1:32 AM, Marko Rauhamaa wrote: > Yes, and lists and dicts and ints and objects and all. No problem there. > > However, when filenames and sys.stdin deal with text, things are getting > iffy. So where do you mark the boundary between the human and the OS? If I create a GUI,

Re: using binary in python

2015-11-09 Thread Marko Rauhamaa
Chris Angelico : > On Tue, Nov 10, 2015 at 12:25 AM, Marko Rauhamaa wrote: >> but personally I would prefer the programming language >> just give me the OS, warts and all. > > Then you don't want Python. The point of Python is to give you data > types like "list", "dict", "int" (not a machine wor

Re: using binary in python

2015-11-09 Thread Chris Angelico
On Tue, Nov 10, 2015 at 12:25 AM, Marko Rauhamaa wrote: > So we have this stack: > > +-+ > | Application | > +-+ > | Python| > +-+ > |UNIX | > +-+ > > The question is, does Python want to be "just a programming language" >

Re: using binary in python

2015-11-09 Thread Marko Rauhamaa
Chris Angelico : > On Mon, Nov 9, 2015 at 9:56 PM, Marko Rauhamaa wrote: >> One of the principal UNIX innovations was to see files as simple byte >> sequences. The operating system would place no semantics on the >> meaning or structure of the bytes. > > And you also want to see those files as co

Re: using binary in python

2015-11-09 Thread Chris Angelico
On Mon, Nov 9, 2015 at 9:56 PM, Marko Rauhamaa wrote: > One of the principal UNIX innovations was to see files as simple byte > sequences. The operating system would place no semantics on the meaning > or structure of the bytes. And you also want to see those files as containing "plain text", rig

Re: using binary in python

2015-11-09 Thread Marko Rauhamaa
Michiel Overtoom : > If you're on Windows, don't forget to include a 'b' in the mode string > of the open() call, otherwise Python will assume that you're opening a > text file. Python has brought that blessing to other operating systems, as well. One of the principal UNIX innovations was to see

Re: using binary in python

2015-11-09 Thread Michiel Overtoom
> On 08 Nov 2015, at 22:27, kent nyberg wrote: > > Well, lets assume I want to write and read binary. How is it done? With the functions 'open()' and 'read()' and 'write()'. If you're on Windows, don't forget to include a 'b' in the mode string of the open() call, otherwise Python will assum

Re: using binary in python

2015-11-09 Thread Jussi Piitulainen
kent nyberg writes: [- -] > Well, lets assume I want to write and read binary. How is it done? [- -] You open the file with mode "wb" (to write binary) or "rb" (to read binary), and then you write or read bytes (eight-bit units). >>> data = '"binääridataa"\n'.encode('utf-8') >>> f = open(

using binary in python

2015-11-09 Thread kent nyberg
Hi there, Lets say I want to play around with binary files in python. Opening and using files in python is something that I think I've sort of got the hang of. The thing im wondering about is binary files. While searching for binary and python I started reading about bin(). I can use bin() to conv