]> granicus.if.org Git - python/commitdiff
revert r69777 since all the experts agree that extra import lines distract from the...
authorBenjamin Peterson <benjamin@python.org>
Fri, 20 Feb 2009 03:31:23 +0000 (03:31 +0000)
committerBenjamin Peterson <benjamin@python.org>
Fri, 20 Feb 2009 03:31:23 +0000 (03:31 +0000)
31 files changed:
Doc/howto/doanddont.rst
Doc/howto/webservers.rst
Doc/includes/sqlite3/adapter_datetime.py
Doc/library/asyncore.rst
Doc/library/cgi.rst
Doc/library/configparser.rst
Doc/library/cookielib.rst
Doc/library/crypt.rst
Doc/library/csv.rst
Doc/library/difflib.rst
Doc/library/doctest.rst
Doc/library/fcntl.rst
Doc/library/getopt.rst
Doc/library/gl.rst
Doc/library/imaplib.rst
Doc/library/imputil.rst
Doc/library/logging.rst
Doc/library/modulefinder.rst
Doc/library/pickle.rst
Doc/library/poplib.rst
Doc/library/signal.rst
Doc/library/sqlite3.rst
Doc/library/ssl.rst
Doc/library/stat.rst
Doc/library/sunaudio.rst
Doc/library/termios.rst
Doc/library/traceback.rst
Doc/library/xmlrpclib.rst
Doc/tutorial/interactive.rst
Doc/tutorial/stdlib2.rst
Doc/whatsnew/2.6.rst

index b4f271ecc2644ab6e9bc14ccc80117df4c36359f..a56fb8c13e87dfbf98d926b66bf87d7471065459 100644 (file)
@@ -267,8 +267,7 @@ sequence with comparable semantics, for example, yet many people write their own
 :func:`max`/:func:`min`. Another highly useful function is :func:`reduce`. A
 classical use of :func:`reduce` is something like ::
 
-   import operator
-   import sys
+   import sys, operator
    nums = map(float, sys.argv[1:])
    print reduce(operator.add, nums)/len(nums)
 
index 1b8e0411e8266285a6a6fe8c5370538408196c7d..6e0c815c4ef17ec90622aa1d5bbb5ac950c847dc 100644 (file)
@@ -99,8 +99,7 @@ simple CGI program::
     # -*- coding: UTF-8 -*-
 
     # enable debugging
-    import cgitb
-    cgitb.enable()
+    import cgitb; cgitb.enable()
 
     print "Content-Type: text/plain;charset=utf-8"
     print
@@ -280,9 +279,7 @@ following WSGI-application::
     # -*- coding: UTF-8 -*-
 
     from cgi import escape
-    import os
-    import sys
-
+    import sys, os
     from flup.server.fcgi import WSGIServer
 
     def app(environ, start_response):
index 56e533f1e37adec02ea64f9390242b780a3c7a79..34604985c124b586a603c408c9aff3ae04e2cabd 100644 (file)
@@ -1,6 +1,5 @@
-import datetime
 import sqlite3
-import time
+import datetime, time
 
 def adapt_datetime(ts):
     return time.mktime(ts.timetuple())
index e7ef9255ed1ce3b4518bb910e61c547855756a3d..4736a9c11108554a8c00d2cb52b7cc01c88c1321 100644 (file)
@@ -246,8 +246,7 @@ asyncore Example basic HTTP client
 Here is a very basic HTTP client that uses the :class:`dispatcher` class to
 implement its socket handling::
 
-   import asyncore
-   import socket
+   import asyncore, socket
 
    class http_client(asyncore.dispatcher):
 
index 6ad061f9818ec2fc8ffd14653622e447802564c6..0248284b8722e87e96c6a46fe55456942f67cbb8 100644 (file)
@@ -67,20 +67,16 @@ Begin by writing ``import cgi``.  Do not use ``from cgi import *`` --- the
 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 following::
+When you write a new script, consider adding the line::
 
-   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 something like this::
-
-   import cgitb
+instead, with a line like this::
 
-   cgitb.enable(display=0, logdir="/tmp")
+   import cgitb; 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
index a04badb624307534a2090188ffff86fa67bb3a44..1de11b9a627109950e4b680d9ea8897c32c92e82 100644 (file)
@@ -231,8 +231,7 @@ RawConfigParser Objects
    load the required file or files using :meth:`readfp` before calling :meth:`read`
    for any optional files::
 
-      import ConfigParser
-      import os
+      import ConfigParser, os
 
       config = ConfigParser.ConfigParser()
       config.readfp(open('defaults.cfg'))
index c52fca3ca3becc81a64b7a49ad3bfbaf922c2da3..12a12a03ac0f517cb485d9582157498811387d54 100644 (file)
@@ -747,8 +747,7 @@ Examples
 
 The first example shows the most common usage of :mod:`cookielib`::
 
-   import cookielib
-   import urllib2
+   import cookielib, urllib2
    cj = cookielib.CookieJar()
    opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
    r = opener.open("http://example.com/")
@@ -756,9 +755,7 @@ The first example shows the most common usage of :mod:`cookielib`::
 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 cookielib
-   import os
-   import urllib2
+   import os, cookielib, urllib2
    cj = cookielib.MozillaCookieJar()
    cj.load(os.path.join(os.environ["HOME"], ".netscape/cookies.txt"))
    opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
index f8d4f92cc584d43040872d6f7fbf1fb6cfa951a9..2f037c7e0e946959e03bed687282b05e19aa5bb7 100644 (file)
@@ -45,9 +45,7 @@ this module.
 
 A simple example illustrating typical use::
 
-   import crypt
-   import getpass
-   import pwd
+   import crypt, getpass, pwd
 
    def login():
        username = raw_input('Python login:')
index 4b402b1cbc583c0510105f97fca221039fadcd7b..f19574b273f6d34c7b603bc3af129144ad9068fe 100644 (file)
@@ -460,8 +460,7 @@ Registering a new dialect::
 
 A slightly more advanced use of the reader --- catching and reporting errors::
 
-   import csv
-   import sys
+   import csv, sys
    filename = "some.csv"
    reader = csv.reader(open(filename, "rb"))
    try:
@@ -507,9 +506,7 @@ For all other encodings the following :class:`UnicodeReader` and
 parameter in their constructor and make sure that the data passes the real
 reader or writer encoded as UTF-8::
 
-   import codecs
-   import cStringIO
-   import csv
+   import csv, codecs, cStringIO
 
    class UTF8Recoder:
        """
index 701c5d5adc439d6869269cbf92b2e88dcbab80bc..addd813564ba077981b4087222609ca29f15fb75 100644 (file)
@@ -708,11 +708,7 @@ It is also contained in the Python source distribution, as
 
    """
 
-   import difflib
-   import os
-   import optparse
-   import sys
-   import time
+   import sys, os, time, difflib, optparse
 
    def main():
         # Configure the option parser
index 49db1c89e3c3f9f3b9e7b943a4c517d08ab057f0..31e6d0f72d69d3bfbf338e0768f14d82b319ce6f 100644 (file)
@@ -951,11 +951,9 @@ Python 2.4, :mod:`doctest`'s :class:`Tester` class is deprecated, and
 test suites from modules and text files containing doctests.  These test suites
 can then be run using :mod:`unittest` test runners::
 
-   import doctest
    import unittest
-
-   import my_module_with_doctests
-   import my_other_module_with_doctests
+   import doctest
+   import my_module_with_doctests, and_another
 
    suite = unittest.TestSuite()
    for mod in my_module_with_doctests, and_another:
index c9118f09182fc78224e0e3e78baec569d21dc901..b3b977f9345d9223b48fe5169e0582c8b45de5d8 100644 (file)
@@ -133,9 +133,7 @@ The module defines the following functions:
 
 Examples (all on a SVR4 compliant system)::
 
-   import fcntl
-   import os
-   import struct
+   import struct, fcntl, os
 
    f = open(...)
    rv = fcntl.fcntl(f, fcntl.F_SETFL, os.O_NDELAY)
index 78958eea25228271ad378fa8ef63729855306518..2c0fad9ef066c171f0355e425b022bfb554a6130 100644 (file)
@@ -114,8 +114,7 @@ Using long option names is equally easy:
 
 In a script, typical usage is something like this::
 
-   import getopt
-   import sys
+   import getopt, sys
 
    def main():
        try:
index 6a0a92a1be5d15c71e19aa121424e89f7ffb83fe..cbc175ad154802b52b4e0c2b977c67191111ec5d 100644 (file)
@@ -124,9 +124,7 @@ The following functions are non-standard or have special argument conventions:
 
 Here is a tiny but complete example GL program in Python::
 
-   import gl
-   import GL
-   import time
+   import gl, GL, time
 
    def main():
        gl.foreground()
index e0b824e1c3544c60429dda876ed279d61314d231..e18d7d54248763026f1f2da85b7e516181c528b1 100644 (file)
@@ -521,8 +521,7 @@ IMAP4 Example
 Here is a minimal example (without error checking) that opens a mailbox and
 retrieves and prints all messages::
 
-   import getpass
-   import imaplib
+   import getpass, imaplib
 
    M = imaplib.IMAP4()
    M.login(getpass.getuser(), getpass.getpass())
index d36d1a012a5f0190aebe9c9349cbdc093a0b1b73..09a41f69c6d6997c06b26d171bdff9b309f34e83 100644 (file)
@@ -112,9 +112,7 @@ This code is intended to be read, not executed.  However, it does work
 
 ::
 
-   import __builtin__
-   import imp
-   import sys
+   import sys, imp, __builtin__
 
    # Replacement for __import__()
    def import_hook(name, globals=None, locals=None, fromlist=None):
index 554318a1ee94e1732b10e12174994daf5ce0b4c3..8226661856f722820f836dcc6fdab15f5b9db676 100644 (file)
@@ -1347,8 +1347,7 @@ Let's say you want to send logging events across a network, and handle them at
 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
-   import logging.handlers
+   import logging, logging.handlers
 
    rootLogger = logging.getLogger('')
    rootLogger.setLevel(logging.DEBUG)
@@ -2601,9 +2600,7 @@ properly preceded with the binary-encoded length, as the new logging
 configuration::
 
     #!/usr/bin/env python
-    import socket
-    import struct
-    import sys
+    import socket, sys, struct
 
     data_to_send = open(sys.argv[1], "r").read()
 
index 9af53358dfdd20dc48be23e70daac2ed6b8b7ac6..a086206df72e88d6abec2ad549b95e4fba90e708 100644 (file)
@@ -64,8 +64,7 @@ Example usage of :class:`ModuleFinder`
 
 The script that is going to get analyzed later on (bacon.py)::
 
-   import itertools
-   import re
+   import re, itertools
 
    try:
        import baconhameggs
index 8d153ec71fa3119ab106d3c4aa7827084e0c888a..a99dc862f4da3a5783a4e7781886e1e81e6485f0 100644 (file)
@@ -708,8 +708,7 @@ The following example reads the resulting pickled data.  When reading a
 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 pickle
-   import pprint
+   import pprint, pickle
 
    pkl_file = open('data.pkl', 'rb')
 
index 891e20e536bed13de2f750d14387a2222120131c..e5f693d288372fd929cb4fb8417417d3af2b03c8 100644 (file)
@@ -182,8 +182,7 @@ POP3 Example
 Here is a minimal example (without error checking) that opens a mailbox and
 retrieves and prints all messages::
 
-   import getpass
-   import poplib
+   import getpass, poplib
 
    M = poplib.POP3('localhost')
    M.user(getpass.getuser())
index fbcee6bd563a2eb030db2b34e7bb884bf5739bd8..3793a89b03a909bb0cbf143db057bc40ba553d1c 100644 (file)
@@ -228,8 +228,7 @@ serial device that may not be turned on, which would normally cause the
 before opening the file; if the operation takes too long, the alarm signal will
 be sent, and the handler raises an exception. ::
 
-   import os
-   import signal
+   import signal, os
 
    def handler(signum, frame):
        print 'Signal handler called with signal', signum
index 1a44284ed884766ac878a43322780aae0eed649c..d031c909755cf9ee09b66fcf06f280d767e145ef 100644 (file)
@@ -423,8 +423,7 @@ Connection Objects
    Example::
 
       # Convert file existing_db.db to SQL dump file dump.sql
-      import os
-      import sqlite3
+      import sqlite3, os
 
       con = sqlite3.connect('existing_db.db')
       with open('dump.sql', 'w') as f:
index 572c5666e59a746227325db5f4bcc33209df9cbf..30f1fea9d1b85da82ea6abc2cff386fe424d7543 100644 (file)
@@ -481,9 +481,7 @@ Client-side operation
 This example connects to an SSL server, prints the server's address and certificate,
 sends some bytes, and reads part of the response::
 
-   import pprint
-   import socket
-   import ssl
+   import socket, ssl, pprint
 
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
 
@@ -537,8 +535,7 @@ For server operation, typically you'd need to have a server certificate, and pri
 You'd open a socket, bind it to a port, call :meth:`listen` on it, then start waiting for clients
 to connect::
 
-   import socket
-   import ssl
+   import socket, ssl
 
    bindsocket = socket.socket()
    bindsocket.bind(('myaddr.mydomain.com', 10023))
index 835f4485bf7fcbaa514dc56d66641b7d8f0681a9..430bb23fee8f089a8d1b610502e59635a4573431 100644 (file)
@@ -139,8 +139,7 @@ on the implementation of the underlying system call.
 
 Example::
 
-   import os
-   import sys
+   import os, sys
    from stat import *
 
    def walktree(top, callback):
index 4908cb4dfff574c9b5ee10cc9e8af013f19f8d00..4d67b21eb9a389919c2b8a9349425d930f76467a 100644 (file)
@@ -135,13 +135,11 @@ methods (except ``control`` objects which only provide :meth:`getinfo`,
 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)
 
index 38da7b493c94879081f211795a51b18ebf14bcfe..4847949a49b56fcbd30126356544c500fdf05466 100644 (file)
@@ -91,8 +91,7 @@ technique using a separate :func:`tcgetattr` call and a :keyword:`try` ...
 exactly no matter what happens::
 
    def getpass(prompt = "Password: "):
-       import sys
-       import termios
+       import termios, sys
        fd = sys.stdin.fileno()
        old = termios.tcgetattr(fd)
        new = termios.tcgetattr(fd)
index 29b09ae5313c3a78125c1a4f60fc7a8e380aada8..126003785775b7d7b035e786fc82c9b65ba29436 100644 (file)
@@ -145,8 +145,7 @@ less useful than) the standard Python interactive interpreter loop.  For a more
 complete implementation of the interpreter loop, refer to the :mod:`code`
 module. ::
 
-   import sys
-   import traceback
+   import sys, traceback
 
    def run_user_code(envdir):
        source = raw_input(">>> ")
@@ -166,8 +165,7 @@ module. ::
 The following example demonstrates the different ways to print and format the
 exception and traceback::
 
-   import sys
-   import traceback
+   import sys, traceback
 
    def lumberjack():
        bright_side_of_death()
index f5aa40ecc268c153aef6d0523cc7960474ea3d18..4035f8eeba639709bfd78e431bf46d5d1a2e1f90 100644 (file)
@@ -551,8 +551,7 @@ transport.  The following example shows how:
 
 ::
 
-   import httplib
-   import xmlrpclib
+   import xmlrpclib, httplib
 
    class ProxiedTransport(xmlrpclib.Transport):
        def set_proxy(self, proxy):
index 90981e54a92c760b35ac3db0916807b538ec8aef..6a439bde12ace7721cecb418c458eb158955fc69 100644 (file)
@@ -99,8 +99,7 @@ Automatic completion of variable and module names is optionally available.  To
 enable it in the interpreter's interactive mode, add the following to your
 startup file: [#]_  ::
 
-   import readline
-   import rlcompleter
+   import rlcompleter, readline
    readline.parse_and_bind('tab: complete')
 
 This binds the :kbd:`Tab` key to the completion function, so hitting the
index b50a3b9f2522f02042615d660a3760b1d0e9e169..8faa3604640c93981cdb2ee6535aa7c42bc9d974 100644 (file)
@@ -170,8 +170,7 @@ case is running I/O in parallel with computations in another thread.
 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
-   import zipfile
+   import threading, zipfile
 
    class AsyncZip(threading.Thread):
        def __init__(self, infile, outfile):
index 17ee766c442d77e2024ce7c7d7632cefce527e99..f04f194376dd404e0e42b8cf9e827f673e04da0f 100644 (file)
@@ -473,8 +473,7 @@ statement both starts a database transaction and acquires a thread lock::
 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 sys
-   import urllib
+   import urllib, sys
    from contextlib import closing
 
    with closing(urllib.urlopen('http://www.yahoo.com')) as f: