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


Groups > comp.lang.python > #98772

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

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From kent nyberg <kent@z-sverige.nu>
Newsgroups comp.lang.python
Subject Re: Problems using struct pack/unpack in files, and reading them.
Date Fri, 13 Nov 2015 16:34:50 -0500
Lines 9
Message-ID <mailman.309.1447450493.16136.python-list@python.org> (permalink)
References <20151113192045.GA9913@z-sverige.nu> <CALwzidnL1N8efgJfM-EKTgqzmDjg2QwcZVVmDXJB2_QGyFnExA@mail.gmail.com> <20151113201510.GA10107@z-sverige.nu> <mailman.306.1447448484.16136.python-list@python.org> <n25k27$m37$1@reader1.panix.com>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
X-Trace news.uni-berlin.de 4dG3SEHR43FQxo4h4psWgwG8SJeNcRFFBYPx+t1H4ClQ==
Return-Path <kent@z-sverige.nu>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.014
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'works.': 0.07; 'assumed': 0.09; 'subject:files': 0.09; 'subject:using': 0.09; 'python': 0.10; 'index': 0.13; 'file,': 0.15; 'alot': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:Problems': 0.16; 'char': 0.18; 'of.': 0.18; 'forgot': 0.23; 'header:In-Reply-To:1': 0.24; 'sort': 0.25; 'header:User-Agent:1': 0.26; 'subject:/': 0.30; 'though,': 0.32; 'problem': 0.33; 'next': 0.35; 'to:addr:python- list': 0.36; 'subject:: ': 0.37; 'say': 0.37; 'thanks': 0.37; 'charset:us-ascii': 0.37; 'to:addr:python.org': 0.40; 'where': 0.40; 'times': 0.63; 'places': 0.64; 'due': 0.65; 'received:178': 0.72; '10th': 0.84; 'subject:pack': 0.84
Content-Disposition inline
In-Reply-To <n25k27$m37$1@reader1.panix.com>
User-Agent Mutt/1.5.23 (2014-03-12)
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:98772

Show key headers only | View raw


The main problem was that I forgot to do seek(0).  Thanks alot people.

Though, as many times before, the problem was due to misunderstanding of how python works.
I assumed file.read()[xx:yy] was to be understood as,   in the file, read from index xx to place yy.
That is,  [10:20]  was the same as,   read from 10th char to 20th.  Sort of.


Is it true then to say that every .read  of a file, places an index-offset (?) from where the next read starts?
That is, I need to rewind the file, or else the read will start from where the last read stopped?

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | 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 14:00 -0700
  Re: Problems using struct pack/unpack in files, and reading them. Grant Edwards <invalid@invalid.invalid> - 2015-11-13 21:17 +0000
    Re: Problems using struct pack/unpack in files, and reading them. kent nyberg <kent@z-sverige.nu> - 2015-11-13 16:34 -0500
      Re: Problems using struct pack/unpack in files, and reading them. Grant Edwards <invalid@invalid.invalid> - 2015-11-13 21:44 +0000

csiph-web