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


Groups > comp.lang.python > #98509

Re: using binary in python

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Michiel Overtoom <motoom@xs4all.nl>
Newsgroups comp.lang.python
Subject Re: using binary in python
Date Mon, 9 Nov 2015 11:40:20 +0100
Lines 17
Message-ID <mailman.168.1447065689.16136.python-list@python.org> (permalink)
References <20151108212706.GA29701@z-sverige.nu>
Mime-Version 1.0 (Mac OS X Mail 8.2 \(2104\))
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding quoted-printable
X-Trace news.uni-berlin.de s9NbA2JmCVdt1JhwAazXBQL1qtvama1FEWgkDKz1IdWg==
Return-Path <motoom@xs4all.nl>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'binary': 0.05; 'open()': 0.09; 'subject:using': 0.09; 'python': 0.10; 'assume': 0.11; 'files.': 0.13; 'subject:python': 0.14; "'b'": 0.16; 'binary.': 0.16; 'from:addr:xs4all.nl': 0.16; 'received:194.109': 0.16; 'received:194.109.24': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'received:xs4all.nl': 0.16; 'wrote:': 0.16; 'string': 0.17; 'module,': 0.18; 'file.': 0.22; 'header:In- Reply-To:1': 0.24; 'values': 0.28; 'windows,': 0.29; 'convert': 0.29; 'to:name:python-list': 0.30; 'call,': 0.33; 'lets': 0.33; 'text': 0.35; 'nov': 0.35; 'mode': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'charset:us-ascii': 0.37; 'to:addr:python.org': 0.40; 'forget': 0.60; 'header:Message-Id:1': 0.61; 'greetings,': 0.61; 'received:194': 0.61; 'received:nl': 0.72; 'kent': 0.84
In-Reply-To <20151108212706.GA29701@z-sverige.nu>
X-Mailer Apple Mail (2.2104)
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:98509

Show key headers only | View raw


> On 08 Nov 2015, at 22:27, kent nyberg <kent@z-sverige.nu> 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 assume that you're opening a text file.

You also might want to look into the 'struct' module, functions 'pack()' and 'unpack()'. They convert python values to their binary representation which is used in binary files.

Greetings,


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


Thread

Re: using binary in python Michiel Overtoom <motoom@xs4all.nl> - 2015-11-09 11:40 +0100
  Re: using binary in python Marko Rauhamaa <marko@pacujo.net> - 2015-11-09 12:56 +0200
    Re: using binary in python Chris Angelico <rosuav@gmail.com> - 2015-11-09 22:04 +1100
      Re: using binary in python Marko Rauhamaa <marko@pacujo.net> - 2015-11-09 15:25 +0200
        Re: using binary in python Chris Angelico <rosuav@gmail.com> - 2015-11-10 00:52 +1100
          Re: using binary in python Marko Rauhamaa <marko@pacujo.net> - 2015-11-09 16:32 +0200
            Re: using binary in python Chris Angelico <rosuav@gmail.com> - 2015-11-10 02:17 +1100
              Re: using binary in python Marko Rauhamaa <marko@pacujo.net> - 2015-11-09 17:46 +0200
                Re: using binary in python Chris Angelico <rosuav@gmail.com> - 2015-11-10 02:57 +1100
                Re: using binary in python Marko Rauhamaa <marko@pacujo.net> - 2015-11-09 18:17 +0200

csiph-web