[Python-checkins] r69777 - in python/trunk/Doc: howto/doanddont.rst howto/webservers.rst includes/sqlite3/adapter_datetime.py library/asyncore.rst library/cgi.rst library/configparser.rst library/cookielib.rst library/crypt.rst library/csv.rst library/difflib.rst library/doctest.rst library/fcntl.rst library/getopt.rst library/gl.rst library/imaplib.rst library/imputil.rst library/logging.rst library/modulefinder.rst library/pickle.rst library/poplib.rst library/signal.rst library/sqlite3.rst library/ssl.rst library/stat.rst library/sunaudio.rst library/termios.rst library/traceback.rst library/xmlrpclib.rst tutorial/interactive.rst tutorial/stdlib2.rst whatsnew/2.6.rst

jeroen.ruigrok python-checkins at python.org
Thu Feb 19 19:52:21 CET 2009


Author: jeroen.ruigrok
Date: Thu Feb 19 19:52:21 2009
New Revision: 69777
Log:
Since we recommend one module per import line, reflect this also in the
documentation.
Modified:
 python/trunk/Doc/howto/doanddont.rst
 python/trunk/Doc/howto/webservers.rst
 python/trunk/Doc/includes/sqlite3/adapter_datetime.py
 python/trunk/Doc/library/asyncore.rst
 python/trunk/Doc/library/cgi.rst
 python/trunk/Doc/library/configparser.rst
 python/trunk/Doc/library/cookielib.rst
 python/trunk/Doc/library/crypt.rst
 python/trunk/Doc/library/csv.rst
 python/trunk/Doc/library/difflib.rst
 python/trunk/Doc/library/doctest.rst
 python/trunk/Doc/library/fcntl.rst
 python/trunk/Doc/library/getopt.rst
 python/trunk/Doc/library/gl.rst
 python/trunk/Doc/library/imaplib.rst
 python/trunk/Doc/library/imputil.rst
 python/trunk/Doc/library/logging.rst
 python/trunk/Doc/library/modulefinder.rst
 python/trunk/Doc/library/pickle.rst
 python/trunk/Doc/library/poplib.rst
 python/trunk/Doc/library/signal.rst
 python/trunk/Doc/library/sqlite3.rst
 python/trunk/Doc/library/ssl.rst
 python/trunk/Doc/library/stat.rst
 python/trunk/Doc/library/sunaudio.rst
 python/trunk/Doc/library/termios.rst
 python/trunk/Doc/library/traceback.rst
 python/trunk/Doc/library/xmlrpclib.rst
 python/trunk/Doc/tutorial/interactive.rst
 python/trunk/Doc/tutorial/stdlib2.rst
 python/trunk/Doc/whatsnew/2.6.rst
Modified: python/trunk/Doc/howto/doanddont.rst
==============================================================================
--- python/trunk/Doc/howto/doanddont.rst	(original)
+++ python/trunk/Doc/howto/doanddont.rst	Thu Feb 19 19:52:21 2009
@@ -267,7 +267,8 @@
 :func:`max`/:func:`min`. Another highly useful function is :func:`reduce`. A
 classical use of :func:`reduce` is something like ::
 
- import sys, operator
+ import operator
+ import sys
 nums = map(float, sys.argv[1:])
 print reduce(operator.add, nums)/len(nums)
 
Modified: python/trunk/Doc/howto/webservers.rst
==============================================================================
--- python/trunk/Doc/howto/webservers.rst	(original)
+++ python/trunk/Doc/howto/webservers.rst	Thu Feb 19 19:52:21 2009
@@ -99,7 +99,8 @@
 # -*- coding: UTF-8 -*-
 
 # enable debugging
- import cgitb; cgitb.enable()
+ import cgitb
+ cgitb.enable()
 
 print "Content-Type: text/plain;charset=utf-8"
 print
@@ -279,7 +280,9 @@
 # -*- coding: UTF-8 -*-
 
 from cgi import escape
- import sys, os
+ import os
+ import sys
+
 from flup.server.fcgi import WSGIServer
 
 def app(environ, start_response):
Modified: python/trunk/Doc/includes/sqlite3/adapter_datetime.py
==============================================================================
--- python/trunk/Doc/includes/sqlite3/adapter_datetime.py	(original)
+++ python/trunk/Doc/includes/sqlite3/adapter_datetime.py	Thu Feb 19 19:52:21 2009
@@ -1,5 +1,6 @@
+import datetime
 import sqlite3
-import datetime, time
+import time
 
 def adapt_datetime(ts):
 return time.mktime(ts.timetuple())
Modified: python/trunk/Doc/library/asyncore.rst
==============================================================================
--- python/trunk/Doc/library/asyncore.rst	(original)
+++ python/trunk/Doc/library/asyncore.rst	Thu Feb 19 19:52:21 2009
@@ -246,7 +246,8 @@
 Here is a very basic HTTP client that uses the :class:`dispatcher` class to
 implement its socket handling::
 
- import asyncore, socket
+ import asyncore
+ import socket
 
 class http_client(asyncore.dispatcher):
 
Modified: python/trunk/Doc/library/cgi.rst
==============================================================================
--- python/trunk/Doc/library/cgi.rst	(original)
+++ python/trunk/Doc/library/cgi.rst	Thu Feb 19 19:52:21 2009
@@ -67,16 +67,20 @@
 module defines all sorts of names for its own use or for backward compatibility
 that you don't want in your namespace.
 
-When you write a new script, consider adding the line::
+When you write a new script, consider adding the following::
 
- import cgitb; cgitb.enable()
+ import cgitb
+
+ cgitb.enable()
 
 This activates a special exception handler that will display detailed reports in
 the Web browser if any errors occur. If you'd rather not show the guts of your
 program to users of your script, you can have the reports saved to files
-instead, with a line like this::
+instead, with something like this::
+
+ import cgitb
 
- import cgitb; cgitb.enable(display=0, logdir="/tmp")
+ cgitb.enable(display=0, logdir="/tmp")
 
 It's very helpful to use this feature during script development. The reports
 produced by :mod:`cgitb` provide information that can save you a lot of time in
Modified: python/trunk/Doc/library/configparser.rst
==============================================================================
--- python/trunk/Doc/library/configparser.rst	(original)
+++ python/trunk/Doc/library/configparser.rst	Thu Feb 19 19:52:21 2009
@@ -231,7 +231,8 @@
 load the required file or files using :meth:`readfp` before calling :meth:`read`
 for any optional files::
 
- import ConfigParser, os
+ import ConfigParser
+ import os
 
 config = ConfigParser.ConfigParser()
 config.readfp(open('defaults.cfg'))
Modified: python/trunk/Doc/library/cookielib.rst
==============================================================================
--- python/trunk/Doc/library/cookielib.rst	(original)
+++ python/trunk/Doc/library/cookielib.rst	Thu Feb 19 19:52:21 2009
@@ -747,7 +747,8 @@
 
 The first example shows the most common usage of :mod:`cookielib`::
 
- import cookielib, urllib2
+ import cookielib
+ import urllib2
 cj = cookielib.CookieJar()
 opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
 r = opener.open("http://example.com/")
@@ -755,7 +756,9 @@
 This example illustrates how to open a URL using your Netscape, Mozilla, or Lynx
 cookies (assumes Unix/Netscape convention for location of the cookies file)::
 
- import os, cookielib, urllib2
+ import cookielib
+ import os
+ import urllib2
 cj = cookielib.MozillaCookieJar()
 cj.load(os.path.join(os.environ["HOME"], ".netscape/cookies.txt"))
 opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
Modified: python/trunk/Doc/library/crypt.rst
==============================================================================
--- python/trunk/Doc/library/crypt.rst	(original)
+++ python/trunk/Doc/library/crypt.rst	Thu Feb 19 19:52:21 2009
@@ -45,7 +45,9 @@
 
 A simple example illustrating typical use::
 
- import crypt, getpass, pwd
+ import crypt
+ import getpass
+ import pwd
 
 def login():
 username = raw_input('Python login:')
Modified: python/trunk/Doc/library/csv.rst
==============================================================================
--- python/trunk/Doc/library/csv.rst	(original)
+++ python/trunk/Doc/library/csv.rst	Thu Feb 19 19:52:21 2009
@@ -460,7 +460,8 @@
 
 A slightly more advanced use of the reader --- catching and reporting errors::
 
- import csv, sys
+ import csv
+ import sys
 filename = "some.csv"
 reader = csv.reader(open(filename, "rb"))
 try:
@@ -506,7 +507,9 @@
 parameter in their constructor and make sure that the data passes the real
 reader or writer encoded as UTF-8::
 
- import csv, codecs, cStringIO
+ import codecs
+ import cStringIO
+ import csv
 
 class UTF8Recoder:
 """
Modified: python/trunk/Doc/library/difflib.rst
==============================================================================
--- python/trunk/Doc/library/difflib.rst	(original)
+++ python/trunk/Doc/library/difflib.rst	Thu Feb 19 19:52:21 2009
@@ -708,7 +708,11 @@
 
 """
 
- import sys, os, time, difflib, optparse
+ import difflib
+ import os
+ import optparse
+ import sys
+ import time
 
 def main():
 # Configure the option parser
Modified: python/trunk/Doc/library/doctest.rst
==============================================================================
--- python/trunk/Doc/library/doctest.rst	(original)
+++ python/trunk/Doc/library/doctest.rst	Thu Feb 19 19:52:21 2009
@@ -951,9 +951,11 @@
 test suites from modules and text files containing doctests. These test suites
 can then be run using :mod:`unittest` test runners::
 
- import unittest
 import doctest
- import my_module_with_doctests, and_another
+ import unittest
+
+ import my_module_with_doctests
+ import my_other_module_with_doctests
 
 suite = unittest.TestSuite()
 for mod in my_module_with_doctests, and_another:
Modified: python/trunk/Doc/library/fcntl.rst
==============================================================================
--- python/trunk/Doc/library/fcntl.rst	(original)
+++ python/trunk/Doc/library/fcntl.rst	Thu Feb 19 19:52:21 2009
@@ -133,7 +133,9 @@
 
 Examples (all on a SVR4 compliant system)::
 
- import struct, fcntl, os
+ import fcntl
+ import os
+ import struct
 
 f = open(...)
 rv = fcntl.fcntl(f, fcntl.F_SETFL, os.O_NDELAY)
Modified: python/trunk/Doc/library/getopt.rst
==============================================================================
--- python/trunk/Doc/library/getopt.rst	(original)
+++ python/trunk/Doc/library/getopt.rst	Thu Feb 19 19:52:21 2009
@@ -114,7 +114,8 @@
 
 In a script, typical usage is something like this::
 
- import getopt, sys
+ import getopt
+ import sys
 
 def main():
 try:
Modified: python/trunk/Doc/library/gl.rst
==============================================================================
--- python/trunk/Doc/library/gl.rst	(original)
+++ python/trunk/Doc/library/gl.rst	Thu Feb 19 19:52:21 2009
@@ -124,7 +124,9 @@
 
 Here is a tiny but complete example GL program in Python::
 
- import gl, GL, time
+ import gl
+ import GL
+ import time
 
 def main():
 gl.foreground()
Modified: python/trunk/Doc/library/imaplib.rst
==============================================================================
--- python/trunk/Doc/library/imaplib.rst	(original)
+++ python/trunk/Doc/library/imaplib.rst	Thu Feb 19 19:52:21 2009
@@ -521,7 +521,8 @@
 Here is a minimal example (without error checking) that opens a mailbox and
 retrieves and prints all messages::
 
- import getpass, imaplib
+ import getpass
+ import imaplib
 
 M = imaplib.IMAP4()
 M.login(getpass.getuser(), getpass.getpass())
Modified: python/trunk/Doc/library/imputil.rst
==============================================================================
--- python/trunk/Doc/library/imputil.rst	(original)
+++ python/trunk/Doc/library/imputil.rst	Thu Feb 19 19:52:21 2009
@@ -112,7 +112,9 @@
 
 ::
 
- import sys, imp, __builtin__
+ import __builtin__
+ import imp
+ import sys
 
 # Replacement for __import__()
 def import_hook(name, globals=None, locals=None, fromlist=None):
Modified: python/trunk/Doc/library/logging.rst
==============================================================================
--- python/trunk/Doc/library/logging.rst	(original)
+++ python/trunk/Doc/library/logging.rst	Thu Feb 19 19:52:21 2009
@@ -1347,7 +1347,8 @@
 the receiving end. A simple way of doing this is attaching a
 :class:`SocketHandler` instance to the root logger at the sending end::
 
- import logging, logging.handlers
+ import logging
+ import logging.handlers
 
 rootLogger = logging.getLogger('')
 rootLogger.setLevel(logging.DEBUG)
@@ -2600,7 +2601,9 @@
 configuration::
 
 #!/usr/bin/env python
- import socket, sys, struct
+ import socket
+ import struct
+ import sys
 
 data_to_send = open(sys.argv[1], "r").read()
 
Modified: python/trunk/Doc/library/modulefinder.rst
==============================================================================
--- python/trunk/Doc/library/modulefinder.rst	(original)
+++ python/trunk/Doc/library/modulefinder.rst	Thu Feb 19 19:52:21 2009
@@ -64,7 +64,8 @@
 
 The script that is going to get analyzed later on (bacon.py)::
 
- import re, itertools
+ import itertools
+ import re
 
 try:
 import baconhameggs
Modified: python/trunk/Doc/library/pickle.rst
==============================================================================
--- python/trunk/Doc/library/pickle.rst	(original)
+++ python/trunk/Doc/library/pickle.rst	Thu Feb 19 19:52:21 2009
@@ -708,7 +708,8 @@
 pickle-containing file, you should open the file in binary mode because you
 can't be sure if the ASCII or binary format was used. ::
 
- import pprint, pickle
+ import pickle
+ import pprint
 
 pkl_file = open('data.pkl', 'rb')
 
Modified: python/trunk/Doc/library/poplib.rst
==============================================================================
--- python/trunk/Doc/library/poplib.rst	(original)
+++ python/trunk/Doc/library/poplib.rst	Thu Feb 19 19:52:21 2009
@@ -182,7 +182,8 @@
 Here is a minimal example (without error checking) that opens a mailbox and
 retrieves and prints all messages::
 
- import getpass, poplib
+ import getpass
+ import poplib
 
 M = poplib.POP3('localhost')
 M.user(getpass.getuser())
Modified: python/trunk/Doc/library/signal.rst
==============================================================================
--- python/trunk/Doc/library/signal.rst	(original)
+++ python/trunk/Doc/library/signal.rst	Thu Feb 19 19:52:21 2009
@@ -228,7 +228,8 @@
 before opening the file; if the operation takes too long, the alarm signal will
 be sent, and the handler raises an exception. ::
 
- import signal, os
+ import os
+ import signal
 
 def handler(signum, frame):
 print 'Signal handler called with signal', signum
Modified: python/trunk/Doc/library/sqlite3.rst
==============================================================================
--- python/trunk/Doc/library/sqlite3.rst	(original)
+++ python/trunk/Doc/library/sqlite3.rst	Thu Feb 19 19:52:21 2009
@@ -423,7 +423,8 @@
 Example::
 
 # Convert file existing_db.db to SQL dump file dump.sql
- import sqlite3, os
+ import os
+ import sqlite3
 
 con = sqlite3.connect('existing_db.db')
 with open('dump.sql', 'w') as f:
Modified: python/trunk/Doc/library/ssl.rst
==============================================================================
--- python/trunk/Doc/library/ssl.rst	(original)
+++ python/trunk/Doc/library/ssl.rst	Thu Feb 19 19:52:21 2009
@@ -481,7 +481,9 @@
 This example connects to an SSL server, prints the server's address and certificate,
 sends some bytes, and reads part of the response::
 
- import socket, ssl, pprint
+ import pprint
+ import socket
+ import ssl
 
 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
 
@@ -535,7 +537,8 @@
 You'd open a socket, bind it to a port, call :meth:`listen` on it, then start waiting for clients
 to connect::
 
- import socket, ssl
+ import socket
+ import ssl
 
 bindsocket = socket.socket()
 bindsocket.bind(('myaddr.mydomain.com', 10023))
Modified: python/trunk/Doc/library/stat.rst
==============================================================================
--- python/trunk/Doc/library/stat.rst	(original)
+++ python/trunk/Doc/library/stat.rst	Thu Feb 19 19:52:21 2009
@@ -139,7 +139,8 @@
 
 Example::
 
- import os, sys
+ import os
+ import sys
 from stat import *
 
 def walktree(top, callback):
Modified: python/trunk/Doc/library/sunaudio.rst
==============================================================================
--- python/trunk/Doc/library/sunaudio.rst	(original)
+++ python/trunk/Doc/library/sunaudio.rst	Thu Feb 19 19:52:21 2009
@@ -135,11 +135,13 @@
 The audio device supports asynchronous notification of various events, through
 the SIGPOLL signal. Here's an example of how you might enable this in Python::
 
+ import fcntl
+ import signal
+ import STROPTS
+
 def handle_sigpoll(signum, frame):
 print 'I got a SIGPOLL update'
 
- import fcntl, signal, STROPTS
-
 signal.signal(signal.SIGPOLL, handle_sigpoll)
 fcntl.ioctl(audio_obj.fileno(), STROPTS.I_SETSIG, STROPTS.S_MSG)
 
Modified: python/trunk/Doc/library/termios.rst
==============================================================================
--- python/trunk/Doc/library/termios.rst	(original)
+++ python/trunk/Doc/library/termios.rst	Thu Feb 19 19:52:21 2009
@@ -91,7 +91,8 @@
 exactly no matter what happens::
 
 def getpass(prompt = "Password: "):
- import termios, sys
+ import sys
+ import termios
 fd = sys.stdin.fileno()
 old = termios.tcgetattr(fd)
 new = termios.tcgetattr(fd)
Modified: python/trunk/Doc/library/traceback.rst
==============================================================================
--- python/trunk/Doc/library/traceback.rst	(original)
+++ python/trunk/Doc/library/traceback.rst	Thu Feb 19 19:52:21 2009
@@ -145,7 +145,8 @@
 complete implementation of the interpreter loop, refer to the :mod:`code`
 module. ::
 
- import sys, traceback
+ import sys
+ import traceback
 
 def run_user_code(envdir):
 source = raw_input(">>> ")
@@ -165,7 +166,8 @@
 The following example demonstrates the different ways to print and format the
 exception and traceback::
 
- import sys, traceback
+ import sys
+ import traceback
 
 def lumberjack():
 bright_side_of_death()
Modified: python/trunk/Doc/library/xmlrpclib.rst
==============================================================================
--- python/trunk/Doc/library/xmlrpclib.rst	(original)
+++ python/trunk/Doc/library/xmlrpclib.rst	Thu Feb 19 19:52:21 2009
@@ -551,7 +551,8 @@
 
 ::
 
- import xmlrpclib, httplib
+ import httplib
+ import xmlrpclib
 
 class ProxiedTransport(xmlrpclib.Transport):
 def set_proxy(self, proxy):
Modified: python/trunk/Doc/tutorial/interactive.rst
==============================================================================
--- python/trunk/Doc/tutorial/interactive.rst	(original)
+++ python/trunk/Doc/tutorial/interactive.rst	Thu Feb 19 19:52:21 2009
@@ -99,7 +99,8 @@
 enable it in the interpreter's interactive mode, add the following to your
 startup file: [#]_ ::
 
- import rlcompleter, readline
+ import readline
+ import rlcompleter
 readline.parse_and_bind('tab: complete')
 
 This binds the :kbd:`Tab` key to the completion function, so hitting the
Modified: python/trunk/Doc/tutorial/stdlib2.rst
==============================================================================
--- python/trunk/Doc/tutorial/stdlib2.rst	(original)
+++ python/trunk/Doc/tutorial/stdlib2.rst	Thu Feb 19 19:52:21 2009
@@ -170,7 +170,8 @@
 The following code shows how the high level :mod:`threading` module can run
 tasks in background while the main program continues to run::
 
- import threading, zipfile
+ import threading
+ import zipfile
 
 class AsyncZip(threading.Thread):
 def __init__(self, infile, outfile):
Modified: python/trunk/Doc/whatsnew/2.6.rst
==============================================================================
--- python/trunk/Doc/whatsnew/2.6.rst	(original)
+++ python/trunk/Doc/whatsnew/2.6.rst	Thu Feb 19 19:52:21 2009
@@ -473,7 +473,8 @@
 Finally, the :func:`closing(object)` function returns *object* so that it can be
 bound to a variable, and calls ``object.close`` at the end of the block. ::
 
- import urllib, sys
+ import sys
+ import urllib
 from contextlib import closing
 
 with closing(urllib.urlopen('http://www.yahoo.com')) as f:


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /