Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #101761
| Path | csiph.com!feeder.erje.net!1.eu.feeder.erje.net!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Tim Chase <python.list@tim.thechases.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: Writing a stream of bytes |
| Date | Fri, 15 Jan 2016 10:08:30 -0600 |
| Lines | 22 |
| Message-ID | <mailman.18.1452874677.15297.python-list@python.org> (permalink) |
| References | <n7b4os$9j2$1@ger.gmane.org> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=US-ASCII |
| Content-Transfer-Encoding | 7bit |
| X-Trace | news.uni-berlin.de Dms3+9BZAZyEcbo7A6bBhglawLI1WiS4tATthJLg5a3Q== |
| Return-Path | <python.list@tim.thechases.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.026 |
| X-Spam-Evidence | '*H*': 0.95; '*S*': 0.00; 'format:': 0.09; 'subject:Writing': 0.09; '-tkc': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'bytes': 0.18; 'file:': 0.22; 'struct': 0.22; 'import': 0.24; 'header:In-Reply- To:1': 0.24; 'clicked': 0.29; 'grouping': 0.29; 'could': 0.35; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:10': 0.37; 'charset:us-ascii': 0.37; 'end': 0.39; 'to:addr:python.org': 0.40; 'received:46': 0.63; 'canonical': 0.91; 'lap': 0.91 |
| X-Sender-Id | wwwh|x-authuser|tim@thechases.com |
| X-Sender-Id | wwwh|x-authuser|tim@thechases.com |
| X-MC-Relay | Neutral |
| X-MailChannels-SenderId | wwwh|x-authuser|tim@thechases.com |
| X-MailChannels-Auth-Id | wwwh |
| X-MC-Loop-Signature | 1452874254546:3995892316 |
| X-MC-Ingress-Time | 1452874254546 |
| In-Reply-To | <n7b4os$9j2$1@ger.gmane.org> |
| X-Mailer | Claws Mail 3.11.1 (GTK+ 2.24.25; x86_64-pc-linux-gnu) |
| X-AuthUser | tim@thechases.com |
| 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:101761 |
Show key headers only | View raw
[sorry, toddler on my lap clicked <send> before I could type]
> import struct
> with open('toto', 'wb') as f: f.write(struct.pack('<4B', *[1,2,3,4]))
This one does what you want. The problem resides in your check:
> I always end up with the following bytes on file:
> !hexdump toto
> 0000000 0201 0403
Hexdump is grouping them. Try the canonical format:
!hexdump -C toto
00000000 01 02 03 04 |....|
00000004
-tkc
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Writing a stream of bytes Tim Chase <python.list@tim.thechases.com> - 2016-01-15 10:08 -0600
csiph-web