Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #66122
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2a.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.002 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'win32': 0.03; 'binary': 0.07; 'string': 0.09; 'bytes.': 0.09; 'encode': 0.09; 'objects)': 0.09; 'python': 0.11; "'w')": 0.16; 'bytes;': 0.16; 'mode,': 0.16; 'str,': 0.16; 'typeerror:': 0.16; 'files.': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'bit': 0.19; 'later': 0.20; 'feb': 0.22; '>>>': 0.22; '(in': 0.22; 'bytes': 0.24; 'skip': 0.24; '(or': 0.24; 'header:In-Reply-To:1': 0.27; 'tim': 0.29; 'message- id:@mail.gmail.com': 0.30; 'skip:( 20': 0.30; '"",': 0.31; 'chase': 0.31; 'sep': 0.31; 'file': 0.32; 'lists': 0.32; 'text': 0.33; '(most': 0.33; "can't": 0.35; 'received:google.com': 0.35; 'subject:?': 0.36; 'to:addr:python-list': 0.38; 'list,': 0.38; 'pm,': 0.38; 'recent': 0.39; '12,': 0.39; 'to:addr:python.org': 0.39; 'read': 0.60; 'ian': 0.60; 'first': 0.61; "you'll": 0.62; 'more': 0.64 |
| 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=7ceYlogGBUcv6qbXNF8X0uflM2eeIMJdWL8AgNmYdhc=; b=lSoHTLQ3brHFKt7b+qzQd0RlwQoi4MFz7LUk4u6nAsFOCX/vjhOhmQc9RLgKNbYonQ S/U2vMlhxuDy4fTu8FKgHNWrhvkvRsg9ci7SJw0CCASU93QrhppNW/S3v8+67na3J4BE n1Gl6QTVU0m9lmIwRijU1BWg9AaCa6kBcZeCb3WXjDA1g0OXf8sIOpJdCHaLT2MMrl2d ygvy61O04KlObzs/lujfH45XRqrU5lOlGFWFpwCRcWKOV70cmfyjT1tSizbdR58/QjnN +aHEhMdoLP71+3Lm4VofBGw5MxusGEfqPiibiWewesZMXt26AE7Cs+F5ISFEPIYBWtLs s3Nw== |
| X-Received | by 10.68.75.9 with SMTP id y9mr54610887pbv.61.1392249714115; Wed, 12 Feb 2014 16:01:54 -0800 (PST) |
| MIME-Version | 1.0 |
| In-Reply-To | <20140212161427.0a9843d5@bigbox.christie.dr> |
| References | <6c76ef4e-8c7c-4199-b30d-c4d55c1061c8@googlegroups.com> <f45edd72-f8c2-4a20-a1f8-47a1814dfaba@googlegroups.com> <CALwzidnFDxRPmJRXjL2idtqYoccGKaqpACbWGTAyFQDz6juWsQ@mail.gmail.com> <20140212161427.0a9843d5@bigbox.christie.dr> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Wed, 12 Feb 2014 17:01:13 -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.6809.1392249723.18130.python-list@python.org> (permalink) |
| Lines | 22 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1392249723 news.xs4all.nl 2840 [2001:888:2000:d::a6]:39687 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:66122 |
Show key headers only | View raw
On Wed, Feb 12, 2014 at 3:14 PM, Tim Chase
<python.list@tim.thechases.com> wrote:
> On 2014-02-12 14:35, Ian Kelly wrote:
>> 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.
>
> To be pedantic, you can only write *bytes* to files, so you need to
> serialize your lists (or other objects) to strings and then encode
> those to bytes; or skip the string and encode your list/object
> directly to bytes.
The file was opened in text mode, not binary mode.
Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:55:48) [MSC v.1600 32 bit (In
tel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> f = open('test.txt', 'w')
>>> f.write(b'hello world')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: must be str, not bytes
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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