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


Groups > comp.lang.python > #39457

Re: NamedTemporaryFile does not match documentation

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.008
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'strings.': 0.07; 'python': 0.09; '22,': 0.09; 'received:209.85.212.54': 0.09; 'tempfile': 0.09; 'subject:not': 0.11; 'argument.': 0.16; 'binary,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'wrote:': 0.17; 'unicode': 0.17; 'feb': 0.19; 'import': 0.21; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'possibly': 0.27; 'subject:skip:d 10': 0.27; 'message-id:@mail.gmail.com': 0.27; 'received:209.85.212': 0.28; '>>>>': 0.29; 'fri,': 0.30; 'to:addr :python-list': 0.33; 'received:google.com': 0.34; 'jason': 0.35; 'received:209.85': 0.35; 'received:209': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'skip:n 10': 0.63; 'more': 0.63; 'skip:n 30': 0.69; '2013': 0.84; 'subject:skip:N 10': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=eF9gKtxaOhwbQZowrmCjQixDzcp5qCC6AXvg4SR9uWw=; b=myuoGG5gqAOkCEZyrJRBN/TW0Vx5pArm8gwph2IcdCZlM8p3M1xzbv7P60yQDHssEO d5HvVv/tf0rv6F/xPrVDY2wF567VRAv7q4t/HeBPxA4eYjj1RvJOB4oC7kGE9rm0140c DJ9ZWSn2m+txqmeOUDDtqDmrb2pJx4qazxZq2t2WzoardQfJwSijEK9vvRpPifSyim8M gsq2930MvCd7JYf2BinzDivnL627TmazPsqvzx2EhSZxBME0Y5HXTmypCfXye44ugs1f jZVAA2objpmlrKdmPa432v1i6Oh77W7dbTw8Ah7uhVNMTSx+5bshy6teumBq7vDzX2o3 7QKw==
MIME-Version 1.0
X-Received by 10.52.88.197 with SMTP id bi5mr28933584vdb.58.1361480092921; Thu, 21 Feb 2013 12:54:52 -0800 (PST)
In-Reply-To <CANy1k1g4eJ+9aBArQm_r8k0iKKuaxf_wzKjdEjOkj7M0J7=N8A@mail.gmail.com>
References <CANy1k1g4eJ+9aBArQm_r8k0iKKuaxf_wzKjdEjOkj7M0J7=N8A@mail.gmail.com>
Date Fri, 22 Feb 2013 07:54:52 +1100
Subject Re: NamedTemporaryFile does not match documentation
From Chris Angelico <rosuav@gmail.com>
To 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 <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2195.1361480101.2939.python-list@python.org> (permalink)
Lines 12
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1361480101 news.xs4all.nl 6908 [2001:888:2000:d::a6]:54600
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:39457

Show key headers only | View raw


On Fri, Feb 22, 2013 at 7:46 AM, Jason Friedman <jsf80238@gmail.com> wrote:
> Python 3.2.2 (default, Feb 14 2012, 08:06:31)
> [GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> from tempfile import NamedTemporaryFile
>>>> f = NamedTemporaryFile(delete=False)

The default 'mode' is 'w+b', meaning that you need to send it binary,
not Unicode strings. Try adding mode='w+' to the constructor, and
possibly also an encoding= argument.

ChrisA

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


Thread

Re: NamedTemporaryFile does not match documentation Chris Angelico <rosuav@gmail.com> - 2013-02-22 07:54 +1100

csiph-web