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


Groups > comp.lang.python > #74425

Re: Do I need to call close on the handle returned by urlopen?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
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; 'tutorial': 0.03; 'from:addr:yahoo.co.uk': 0.04; 'context': 0.07; 'latter': 0.09; 'lawrence': 0.09; 'mentions': 0.09; 'properly.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'suggest': 0.14; 'language.': 0.14; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'all.': 0.16; 'language': 0.16; 'wrote:': 0.18; "hasn't": 0.19; 'subject:need': 0.19; 'header :User-Agent:1': 0.23; '---': 0.24; 'question': 0.24; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'returned': 0.30; 'code': 0.31; 'file': 0.32; 'probably': 0.32; 'says': 0.33; 'updated': 0.34; 'subject:the': 0.34; 'but': 0.35; 'keyword': 0.36; 'subject:?': 0.36; 'should': 0.36; 'handle': 0.38; 'to:addr :python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'is.': 0.60; 'free': 0.61; 'viruses': 0.61; 'protection': 0.63; 'our': 0.64; 'close': 0.67; 'yes': 0.68; 'antivirus': 0.68; 'introduction': 0.68; 'click': 0.77; "'with'": 0.84; 'change?': 0.84; 'subject:handle': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Mark Lawrence <breamoreboy@yahoo.co.uk>
Subject Re: Do I need to call close on the handle returned by urlopen?
Date Mon, 14 Jul 2014 16:20:35 +0100
References <lq0sar$r6e$1@mx1.internetia.pl>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 8bit
X-Gmane-NNTP-Posting-Host host-78-147-184-43.as13285.net
User-Agent Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.6.0
In-Reply-To <lq0sar$r6e$1@mx1.internetia.pl>
X-Antivirus avast! (VPS 140714-0, 14/07/2014), Outbound message
X-Antivirus-Status Clean
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.11799.1405351227.18130.python-list@python.org> (permalink)
Lines 22
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1405351227 news.xs4all.nl 2845 [2001:888:2000:d::a6]:53184
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:74425

Show key headers only | View raw


On 14/07/2014 15:59, krzysztof.zelechowski@syncron.com wrote:
> The tutorial says that I should use "with open" to close the file handle
> properly.  The reference documentation for urlopen mentions that the handle
> returned is like a file handle but the code samples below do not bother to
> close the handle at all.  Isn’t it inconsistent?

Yes it is.  The latter probably hasn't been updated after the 
introduction of the 'with' keyword and context managers.  Would you like 
to click on the "Report a bug" link on the page in question and suggest 
a change?

-- 
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.

Mark Lawrence

---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com

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


Thread

Do I need to call close on the handle returned by urlopen? <krzysztof.zelechowski@syncron.com> - 2014-07-14 16:59 +0200
  Re: Do I need to call close on the handle returned by urlopen? <krzysztof.zelechowski@syncron.com> - 2014-07-14 17:08 +0200
  Re: Do I need to call close on the handle returned by urlopen? Skip Montanaro <skip@pobox.com> - 2014-07-14 10:09 -0500
  Re: Do I need to call close on the handle returned by urlopen? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-07-14 16:20 +0100

csiph-web