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


Groups > comp.lang.python > #39516

Re: NamedTemporaryFile does not match documentation

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.004
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'binary': 0.05; '(it': 0.09; '22,': 0.09; 'snippet': 0.09; 'bug': 0.10; 'subject:not': 0.11; 'devs': 0.16; 'fix,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'inclined': 0.16; 'reproduce': 0.16; 'wrote:': 0.17; 'bytes': 0.17; 'copied': 0.17; 'specify': 0.17; 'feb': 0.19; '2.x': 0.22; 'patch': 0.24; 'header:In-Reply- To:1': 0.25; 'looks': 0.26; 'subject:skip:d 10': 0.27; 'message- id:@mail.gmail.com': 0.27; 'received:209.85.212': 0.28; 'chris': 0.28; 'mode.': 0.29; 'probably': 0.29; "i'm": 0.29; 'fri,': 0.30; 'mode': 0.30; 'url:python': 0.32; 'file': 0.32; 'could': 0.32; 'docs': 0.33; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'text': 0.34; 'jason': 0.35; 'open': 0.35; 'pm,': 0.35; 'received:209.85': 0.35; 'url:org': 0.36; 'url:library': 0.36; 'thank': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'url:docs': 0.38; 'page': 0.38; 'to:addr:python.org': 0.39; 'easy': 0.60; 'skip:n 10': 0.63; 'love': 0.63; '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=iw6ywOzeQfhVaoDLGC9ZVLs+IWSeKh/6e0ETBoMTrsM=; b=QfIFu//cnDKLVhFTZz+hiEegWhRMnWgYmrAQMvA7SGEKBne8psUHI5FBMbwNX6Pw0s cd4ldkWZb5ZVBrIyZQg/d9R4/nyfbxHHUNHTm8HZYZ4cq4ha0P8Ehx5v/c3RINpJ358J +sR9At+829Za8OoZNYr+000zjwkJk2cfoV2fz79EFhDKLTlmwQzq8+h5yNlUrY7JfqyQ Lp/bt6Uf0r/LAm/C+nv9nGA+2aYrKi10944OwCoBwAWY4v/bHW0VLDKceA2A8nQPpDwe 5ljwKK9CKCQW3b/1fnNZ6d7ts6DAFgYJffBPquCJxFBGRiT27nLjxfrFmuhikj56rRxF LAdg==
MIME-Version 1.0
X-Received by 10.220.219.77 with SMTP id ht13mr366815vcb.66.1361500925090; Thu, 21 Feb 2013 18:42:05 -0800 (PST)
In-Reply-To <CANy1k1i+YX_hAcA+jBbO4w2t37VUoR=YoAUVRBRG0Okc4dqwRA@mail.gmail.com>
References <CANy1k1g4eJ+9aBArQm_r8k0iKKuaxf_wzKjdEjOkj7M0J7=N8A@mail.gmail.com> <kg63kp$742$1@ger.gmane.org> <CANy1k1i+YX_hAcA+jBbO4w2t37VUoR=YoAUVRBRG0Okc4dqwRA@mail.gmail.com>
Date Fri, 22 Feb 2013 13:42:04 +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.2235.1361500927.2939.python-list@python.org> (permalink)
Lines 20
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1361500927 news.xs4all.nl 6899 [2001:888:2000:d::a6]:34064
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:39516

Show key headers only | View raw


On Fri, Feb 22, 2013 at 1:10 PM, Jason Friedman <jsf80238@gmail.com> wrote:
>> NamedTemporaryFile by default opens a file in binary mode ('w+b'). Write
>> bytes or specify text mode.
>>
>>>>> f.write(b"Hello World!\n")
>> 13
>>>>> ft = NamedTemporaryFile('w+', delete=False)
>>>>> ft.write("Hello World!\n")
>> 13
>
> Thank you Chris and Serhiy, that helped.  I'm inclined to open a
> documentation bug because I could not reproduce the code/output
> snippet on page
> http://docs.python.org/release/3.2.2/library/tempfile.html#module-tempfile.

Yep, that looks like a docs bug (it was probably copied straight in
from the 2.x docs). Nice and easy to fix, you could submit a patch
with the bug report and make the devs love you!

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 13:42 +1100

csiph-web