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


Groups > comp.lang.python > #98758

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

From Ian Kelly <ian.g.kelly@gmail.com>
Newsgroups comp.lang.python
Subject Re: Problems using struct pack/unpack in files, and reading them.
Date 2015-11-13 12:36 -0700
Message-ID <mailman.298.1447443424.16136.python-list@python.org> (permalink)
References <20151113192045.GA9913@z-sverige.nu>

Show all headers | View raw


On Fri, Nov 13, 2015 at 12:20 PM, kent nyberg <kent@z-sverige.nu> wrote:
> def LoadCommandAndReact(place_to_read):
>     global RegisterAX
>
>     tmp = place_to_read.read()[RegisterAX:calcsize('HH')]

It looks like you're trying to get a slice of length 4 here, starting
at the value of RegisterAX. What you're actually getting is a slice
starting at the value of RegisterAX and ending at 4. You probably want
this instead:

    tmp = place_to_read.read()[RegisterAX:RegisterAX + calcsize('HH')]

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


Thread

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

csiph-web