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


Groups > comp.lang.python > #66098

Re: Wait... WHAT?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <torriem+gmail@torriefamily.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.009
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'resulting': 0.04; 'assign': 0.07; 'method.': 0.07; 'python': 0.11; 'def': 0.12; "'w')": 0.16; 'competitors': 0.16; 'from:addr:torriem': 0.16; 'from:name:michael torrie': 0.16; 'happened?': 0.16; 'open()': 0.16; 'exception': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'bit': 0.19; 'trying': 0.19; "python's": 0.19; 'header:User-Agent:1': 0.23; 'looks': 0.24; 'question': 0.24; 'right.': 0.26; 'gets': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; "doesn't": 0.30; "i'm": 0.30; 'code': 0.31; 'bug?': 0.31; 'file': 0.32; 'quite': 0.32; 'text': 0.33; 'open': 0.33; 'skip:_ 10': 0.34; 'but': 0.35; 'module.': 0.36; 'doing': 0.36; 'subject:?': 0.36; 'should': 0.36; 'message-id:@gmail.com': 0.38; 'to:addr:python- list': 0.38; 'pm,': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; "you're": 0.61; 'first': 0.61; 'email addr:gmail.com': 0.63; 'provide': 0.64; 'chance': 0.65; 'incorporate': 0.68; 'happened.': 0.84; 'step.': 0.91
X-Virus-Scanned amavisd-new at torriefamily.org
Date Wed, 12 Feb 2014 14:39:40 -0700
From Michael Torrie <torriem@gmail.com>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20131118 Thunderbird/17.0.11
MIME-Version 1.0
To python-list@python.org
Subject Re: Wait... WHAT?
References <6c76ef4e-8c7c-4199-b30d-c4d55c1061c8@googlegroups.com> <f45edd72-f8c2-4a20-a1f8-47a1814dfaba@googlegroups.com>
In-Reply-To <f45edd72-f8c2-4a20-a1f8-47a1814dfaba@googlegroups.com>
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding 7bit
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.6795.1392241217.18130.python-list@python.org> (permalink)
Lines 34
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1392241217 news.xs4all.nl 2920 [2001:888:2000:d::a6]:36988
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:66098

Show key headers only | View raw


On 02/12/2014 01: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.

What happened?  I'm not seeing any exception information.  I do see code
that doesn't quite make sense.

>     def save():
>         target = open ("save.swroc", 'w')
>         target.write([counter, loop, number_of_competitors, competitors])

Do you know what actually gets written? IE do you know what the
resulting text file looks like?

>     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]

This function isn't right.  Question for you, what does open() return?
And if you assign that to "the_array," what makes you think you can
dereference open() as it it were an array?  open() does not provide a
__getitem__() dunder method.

Python is pretty good at doing what you want usually, but you're missing
a step.  Python's not bug-free, but the first suspect in a case like
this is your code.

There's an outside chance you want to explore the "pickle" module.

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