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


Groups > comp.lang.python > #98768 > unrolled thread

Re: Problems using struct pack/unpack in files, and reading them.

Started byIan Kelly <ian.g.kelly@gmail.com>
First post2015-11-13 14:05 -0700
Last post2015-11-13 14:05 -0700
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Problems using struct pack/unpack in files, and reading them. Ian Kelly <ian.g.kelly@gmail.com> - 2015-11-13 14:05 -0700

#98768 — Re: Problems using struct pack/unpack in files, and reading them.

FromIan Kelly <ian.g.kelly@gmail.com>
Date2015-11-13 14:05 -0700
SubjectRe: Problems using struct pack/unpack in files, and reading them.
Message-ID<mailman.307.1447448752.16136.python-list@python.org>
On Fri, Nov 13, 2015 at 1:15 PM, kent nyberg <kent@z-sverige.nu> wrote:
> What bothers me, is the error that says
> unpack requires a string argument of 4 bytes.
> Im thinking in the line of arguments? Does unpack look at the 4 bytes it has read, and tell for some
> reason say that unpacking needs an argument of 4 bytes?  I know that I can set the arguments
> for unpack. I have done that.  It is: unpack('>HH', tmp).
> So either '>HH' or tmp is wrong. Since '>HH' worked for the first run of the function, I assume its correct.
> And as far as I know,   doing .read()[RegisterAX:RegisterAX:+4]  should read the following
> 4 bytes.

By the way, I would strongly suggest that you print or log the value
of repr(tmp) so that you *know* what you're passing to unpack rather
than having to speculate about it.

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web