Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5149742

Browse files
committed
Since we recommend one module per import line, reflect this also in the
documentation.
1 parent a630735 commit 5149742

31 files changed

Lines changed: 96 additions & 42 deletions

Doc/howto/doanddont.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,8 @@ sequence with comparable semantics, for example, yet many people write their own
267267
:func:`max`/:func:`min`. Another highly useful function is :func:`reduce`. A
268268
classical use of :func:`reduce` is something like ::
269269

270-
import sys, operator
270+
import operator
271+
import sys
271272
nums = map(float, sys.argv[1:])
272273
print reduce(operator.add, nums)/len(nums)
273274

Doc/howto/webservers.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ simple CGI program::
9999
# -*- coding: UTF-8 -*-
100100

101101
# enable debugging
102-
import cgitb; cgitb.enable()
102+
import cgitb
103+
cgitb.enable()
103104

104105
print "Content-Type: text/plain;charset=utf-8"
105106
print
@@ -279,7 +280,9 @@ following WSGI-application::
279280
# -*- coding: UTF-8 -*-
280281

281282
from cgi import escape
282-
import sys, os
283+
import os
284+
import sys
285+
283286
from flup.server.fcgi import WSGIServer
284287

285288
def app(environ, start_response):

Doc/includes/sqlite3/adapter_datetime.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import datetime
12
import sqlite3
2-
import datetime, time
3+
import time
34

45
def adapt_datetime(ts):
56
return time.mktime(ts.timetuple())

Doc/library/asyncore.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,8 @@ asyncore Example basic HTTP client
246246
Here is a very basic HTTP client that uses the :class:`dispatcher` class to
247247
implement its socket handling::
248248

249-
import asyncore, socket
249+
import asyncore
250+
import socket
250251

251252
class http_client(asyncore.dispatcher):
252253

Doc/library/cgi.rst

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,20 @@ Begin by writing ``import cgi``. Do not use ``from cgi import *`` --- the
6767
module defines all sorts of names for its own use or for backward compatibility
6868
that you don't want in your namespace.
6969

70-
When you write a new script, consider adding the line::
70+
When you write a new script, consider adding the following::
7171

72-
import cgitb; cgitb.enable()
72+
import cgitb
73+
74+
cgitb.enable()
7375

7476
This activates a special exception handler that will display detailed reports in
7577
the Web browser if any errors occur. If you'd rather not show the guts of your
7678
program to users of your script, you can have the reports saved to files
77-
instead, with a line like this::
79+
instead, with something like this::
80+
81+
import cgitb
7882

79-
import cgitb; cgitb.enable(display=0, logdir="/tmp")
83+
cgitb.enable(display=0, logdir="/tmp")
8084

8185
It's very helpful to use this feature during script development. The reports
8286
produced by :mod:`cgitb` provide information that can save you a lot of time in

Doc/library/configparser.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,8 @@ RawConfigParser Objects
231231
load the required file or files using :meth:`readfp` before calling :meth:`read`
232232
for any optional files::
233233

234-
import ConfigParser, os
234+
import ConfigParser
235+
import os
235236

236237
config = ConfigParser.ConfigParser()
237238
config.readfp(open('defaults.cfg'))

Doc/library/cookielib.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -747,15 +747,18 @@ Examples
747747

748748
The first example shows the most common usage of :mod:`cookielib`::
749749

750-
import cookielib, urllib2
750+
import cookielib
751+
import urllib2
751752
cj = cookielib.CookieJar()
752753
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
753754
r = opener.open("http://example.com/")
754755

755756
This example illustrates how to open a URL using your Netscape, Mozilla, or Lynx
756757
cookies (assumes Unix/Netscape convention for location of the cookies file)::
757758

758-
import os, cookielib, urllib2
759+
import cookielib
760+
import os
761+
import urllib2
759762
cj = cookielib.MozillaCookieJar()
760763
cj.load(os.path.join(os.environ["HOME"], ".netscape/cookies.txt"))
761764
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))

Doc/library/crypt.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ this module.
4545

4646
A simple example illustrating typical use::
4747

48-
import crypt, getpass, pwd
48+
import crypt
49+
import getpass
50+
import pwd
4951

5052
def login():
5153
username = raw_input('Python login:')

Doc/library/csv.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,8 @@ Registering a new dialect::
460460

461461
A slightly more advanced use of the reader --- catching and reporting errors::
462462

463-
import csv, sys
463+
import csv
464+
import sys
464465
filename = "some.csv"
465466
reader = csv.reader(open(filename, "rb"))
466467
try:
@@ -506,7 +507,9 @@ For all other encodings the following :class:`UnicodeReader` and
506507
parameter in their constructor and make sure that the data passes the real
507508
reader or writer encoded as UTF-8::
508509

509-
import csv, codecs, cStringIO
510+
import codecs
511+
import cStringIO
512+
import csv
510513

511514
class UTF8Recoder:
512515
"""

Doc/library/difflib.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,11 @@ It is also contained in the Python source distribution, as
708708

709709
"""
710710

711-
import sys, os, time, difflib, optparse
711+
import difflib
712+
import os
713+
import optparse
714+
import sys
715+
import time
712716

713717
def main():
714718
# Configure the option parser

0 commit comments

Comments
 (0)