[Python-checkins] r69409 - python/trunk/Doc/library/xmlrpclib.rst
georg.brandl
python-checkins at python.org
Sat Feb 7 13:21:18 CET 2009
Author: georg.brandl
Date: Sat Feb 7 13:21:17 2009
New Revision: 69409
Log:
#5174: fix wrong file closing in example.
Modified:
python/trunk/Doc/library/xmlrpclib.rst
Modified: python/trunk/Doc/library/xmlrpclib.rst
==============================================================================
--- python/trunk/Doc/library/xmlrpclib.rst (original)
+++ python/trunk/Doc/library/xmlrpclib.rst Sat Feb 7 13:21:17 2009
@@ -318,9 +318,8 @@
import xmlrpclib
def python_logo():
- handle = open("python_logo.jpg")
- return xmlrpclib.Binary(handle.read())
- handle.close()
+ with open("python_logo.jpg") as handle:
+ return xmlrpclib.Binary(handle.read())
server = SimpleXMLRPCServer(("localhost", 8000))
print "Listening on port 8000..."
@@ -333,9 +332,8 @@
import xmlrpclib
proxy = xmlrpclib.ServerProxy("http://localhost:8000/")
- handle = open("fetched_python_logo.jpg", "w")
- handle.write(proxy.python_logo().data)
- handle.close()
+ with open("fetched_python_logo.jpg", "w") as handle:
+ handle.write(proxy.python_logo().data)
.. _fault-objects:
More information about the Python-checkins
mailing list