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


Groups > comp.lang.python > #66096

Re: Wait... WHAT?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.019
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; 'json': 0.07; 'tkinter': 0.07; 'def': 0.12; 'suggest': 0.14; "'w')": 0.16; 'competitors': 0.16; 'sys.stderr': 0.16; 'exception': 0.16; 'files.': 0.16; 'fix': 0.17; 'wrote:': 0.18; 'wed,': 0.18; 'bit': 0.19; 'module': 0.19; 'trying': 0.19; 'later': 0.20; 'feb': 0.22; 'source': 0.25; 'header:In-Reply-To:1': 0.27; 'appear': 0.29; 'message- id:@mail.gmail.com': 0.30; 'bug?': 0.31; 'post.': 0.31; 'file': 0.32; 'lists': 0.32; 'this.': 0.32; 'open': 0.33; "can't": 0.35; 'received:google.com': 0.35; 'subject:?': 0.36; 'should': 0.36; 'to:addr:python-list': 0.38; 'list,': 0.38; 'pm,': 0.38; '12,': 0.39; 'to:addr:python.org': 0.39; 'enough': 0.39; 'skip:u 10': 0.60; 'read': 0.60; 'up,': 0.60; 'simple': 0.61; 'first': 0.61; "you'll": 0.62; 'incorporate': 0.68; 'happened.': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=b7taXobKjDytgfZATXluDq+dRVrjQnixGLufIXsxZVU=; b=Xl4QWPFBhz2GfTrZXmOLu5wKYCaDrwO4dKAvN/M9j/w4pFO0RFcQJat7c46WBWaiar v7gyBI720oWBhjXoAG+wmnQBekVIaOBjNoU/CcKyLeEdFFh4p8I7/4iFwQkxbKCZbKEK u3fb/DlgK0J8n72+0z1KyDK6TvhabZ0vk4cZ5r/EnnWPR3KP79akBorCuKO1uikZY7sN J1hOyG5NUJV5pEPGxVgCWHLJl+MQlsCHhzl0Pzg2lc0LGE2Ew9KCHi/DhNDg+YW/iOBQ fbjpWCLV1GJVHnBKCRoQYd8ZERtl8zfLuKPdrbt+5aXOZgaiyR6r2BxKuhoGdpzgo3fn 0m1g==
X-Received by 10.66.221.103 with SMTP id qd7mr41380825pac.44.1392240958710; Wed, 12 Feb 2014 13:35:58 -0800 (PST)
MIME-Version 1.0
In-Reply-To <f45edd72-f8c2-4a20-a1f8-47a1814dfaba@googlegroups.com>
References <6c76ef4e-8c7c-4199-b30d-c4d55c1061c8@googlegroups.com> <f45edd72-f8c2-4a20-a1f8-47a1814dfaba@googlegroups.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Wed, 12 Feb 2014 14:35:18 -0700
Subject Re: Wait... WHAT?
To Python <python-list@python.org>
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
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>
Newsgroups comp.lang.python
Message-ID <mailman.6793.1392240962.18130.python-list@python.org> (permalink)
Lines 26
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1392240962 news.xs4all.nl 2898 [2001:888:2000:d::a6]:57353
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:66096

Show key headers only | View raw


On Wed, Feb 12, 2014 at 1:21 PM,  <eneskristo@gmail.com> wrote:
> I think of it as a bit strange. Should I report it as a bug? I was trying to incorporate a save/load, and this happened.
>     def save():
>         target = open ("save.swroc", 'w')
>         target.write([counter, loop, number_of_competitors, competitors])
>     def load():
>         target = open("save.swroc", 'r')
>         the_array = target
>         counter = the_array[0]
>         loop = the_array[1]
>         number_of_competitors = the_array[2]
>         competitors = the_array[3]
> Swroc is an nonexisting file format that i just made up, an acronym of the program

You can't write lists directly to files.  You can only write strings
to files.  To write and read a list, you'll need to first serialize it
and later deserialize it.  Your needs appear simple enough that I
suggest the json module for this.

    json.dump([counter, loop, number_of_competitors, competitors], target)

    [counter, loop, number_of_competitors, competitors] = json.load(target)

It sounds like this may be the source of the exception that tkinter
was trying unsuccessfully to report in your first post.  You should
still fix your sys.stderr so that tkinter can report exceptions.

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


Thread

Wait... WHAT? eneskristo@gmail.com - 2014-02-12 11:43 -0800
  Re: Wait... WHAT? Ian Kelly <ian.g.kelly@gmail.com> - 2014-02-12 13:13 -0700
  Re: Wait... WHAT? eneskristo@gmail.com - 2014-02-12 12:21 -0800
    Re: Wait... WHAT? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-02-12 20:38 +0000
    Re: Wait... WHAT? Ian Kelly <ian.g.kelly@gmail.com> - 2014-02-12 14:35 -0700
    Re: Wait... WHAT? Michael Torrie <torriem@gmail.com> - 2014-02-12 14:39 -0700
    Re: Wait... WHAT? Tim Chase <python.list@tim.thechases.com> - 2014-02-12 16:14 -0600
    Re: Wait... WHAT? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-02-12 23:36 +0000
    Re: Wait... WHAT? Ian Kelly <ian.g.kelly@gmail.com> - 2014-02-12 17:01 -0700
    Re: Wait... WHAT? Tim Chase <python.list@tim.thechases.com> - 2014-02-12 18:44 -0600
    Re: Wait... WHAT? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-02-13 00:59 +0000
    Re: Wait... WHAT? Chris Angelico <rosuav@gmail.com> - 2014-02-13 12:10 +1100
    Re: Wait... WHAT? Tim Chase <python.list@tim.thechases.com> - 2014-02-12 21:29 -0600
    Re: Wait... WHAT? Chris Angelico <rosuav@gmail.com> - 2014-02-13 14:47 +1100
      Re: Wait... WHAT? eneskristo@gmail.com - 2014-02-13 09:46 -0800
        Re: Wait... WHAT? MRAB <python@mrabarnett.plus.com> - 2014-02-13 18:25 +0000
        Re: Wait... WHAT? Michael Torrie <torriem@gmail.com> - 2014-02-13 15:22 -0700
  Re: Wait... WHAT? eneskristo@gmail.com - 2014-02-12 12:43 -0800
    Re: Wait... WHAT? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-02-12 20:56 +0000
      Re: Wait... WHAT? eneskristo@gmail.com - 2014-02-12 12:59 -0800
        Re: Wait... WHAT? Chris Angelico <rosuav@gmail.com> - 2014-02-13 08:17 +1100
        Re: Wait... WHAT? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-02-12 21:23 +0000
    Re: Wait... WHAT? Grant Edwards <invalid@invalid.invalid> - 2014-02-12 23:09 +0000

csiph-web