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


Groups > comp.lang.python > #66199

Re: Wait... WHAT?

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python@mrabarnett.plus.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.004
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'read.': 0.03; 'problem?': 0.07; 'tries': 0.07; 'python': 0.11; 'def': 0.12; "'w')": 0.16; '(assuming': 0.16; 'better?': 0.16; 'competitors': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'received:192.168.1.4': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; ':-)': 0.16; 'wrote:': 0.18; 'header :User-Agent:1': 0.23; 'module,': 0.24; 'text.': 0.24; 'file.': 0.24; 'second': 0.26; 'header:In-Reply-To:1': 0.27; 'lines': 0.31; 'that.': 0.31; 'file': 0.32; 'text': 0.33; 'open': 0.33; 'third': 0.33; "can't": 0.35; 'received:84': 0.35; 'module.': 0.36; 'revert': 0.36; 'subject:?': 0.36; 'list': 0.37; 'list.': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'read': 0.60; "you're": 0.61; 'first': 0.61; 'back': 0.62; 'email addr:gmail.com': 0.63; 'fourth': 0.84; 'opens': 0.91
X-CM-Score 0.00
X-CNFS-Analysis v=2.1 cv=JLW1sq6b c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=sASEtNAQL0YA:10 a=ihvODaAuJD4A:10 a=IkcTkHD0fZMA:10 a=EBOSESyhAAAA:8 a=ZyKMv97ID9UA:10 a=pGLkceISAAAA:8 a=2FHp8gr3cnioVY4v3rUA:9 a=bYRUvOZLVijNvBSe:21 a=oKhfdhAnfzi9AToi:21 a=QEXdDO2ut3YA:10 a=MSl-tDqOz04A:10
X-AUTH mrabarnett:2500
Date Thu, 13 Feb 2014 18:25:16 +0000
From MRAB <python@mrabarnett.plus.com>
User-Agent Mozilla/5.0 (Windows NT 6.3; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0
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> <CALwzidnFDxRPmJRXjL2idtqYoccGKaqpACbWGTAyFQDz6juWsQ@mail.gmail.com> <20140212161427.0a9843d5@bigbox.christie.dr> <ldh0hj$nlj$1@ger.gmane.org> <20140212184432.1df9b491@bigbox.christie.dr> <ldh5cr$bdk$1@ger.gmane.org> <20140212212953.458b810a@bigbox.christie.dr> <mailman.6821.1392263231.18130.python-list@python.org> <8778c4cc-334b-4254-aed7-0f33acbf1d8f@googlegroups.com>
In-Reply-To <8778c4cc-334b-4254-aed7-0f33acbf1d8f@googlegroups.com>
Content-Type text/plain; charset=UTF-8; format=flowed
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.6851.1392315919.18130.python-list@python.org> (permalink)
Lines 44
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1392315920 news.xs4all.nl 2832 [2001:888:2000:d::a6]:43001
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:66199

Show key headers only | View raw


On 2014-02-13 17:46, eneskristo@gmail.com wrote:
> Can we please revert back to the original problem?
>      def save():
 >          target = open ("save.swroc", 'w')

This opens the file for writing text (assuming you're using Python 3).

 >          target.write([counter, loop, number_of_competitors, 
competitors])

This tries to write a list to the file. You can't do that. A list isn't
text.

>      def load():
>          the_array = list(open("save.swroc", 'r'))

This open the file for reading text. Using 'list' will make it read
lines of text and return them as a list.

>          the_array = target

What's 'target'?

>          counter = the_array[0]

This will set 'counter' to the first line of text that was read.

>          loop = the_array[1]

This will set 'loop' to the second line of text.

>          number_of_competitors = the_array[2]

This will set 'number_of_competitors' to the third line of text.

>          competitors = the_array[3]

This will set 'number_of_competitors' to the fourth line of text.

> Is this better?
>
Not really! :-)

Have a look at the "pickle" module, or the "json" 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