8000 fixed more examples that were using u"", print without () and unicode… · python/cpython@985e24d · GitHub
[go: up one dir, main page]

Skip to content

Commit 985e24d

Browse files
committed
fixed more examples that were using u"", print without () and unicode/str instead of str/bytes
1 parent b584505 commit 985e24d

File tree

10 files changed

+50
-52
lines changed

10 files changed

+50
-52
lines changed

Doc/library/exceptions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ The following exceptions are only used as base classes for other exceptions.
5252

5353
The base class for all built-in exceptions. It is not meant to be directly
5454
inherited by user-defined classes (for that use :exc:`Exception`). If
55-
:func:`str` or :func:`unicode` is called on an instance of this class, the
55+
:func:`bytes` or :func:`str` is called on an instance of this class, the
5656
representation of the argument(s) to the instance are returned or the empty
5757
string when there were no arguments. All arguments are stored in :attr:`args`
5858
as a tuple.

Doc/library/json.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ Basic Usage
118118
file-like object).
119119

120120
If *skipkeys* is ``True`` (default: ``False``), then dict keys that are not
121-
of a basic type (:class:`str`, :class:`unicode`, :class:`int`,
121+
of a basic type (:class:`bytes`, :class:`str`, :class:`int`,
122122
:class:`float`, :class:`bool`, ``None``) will be skipped instead of raising a
123123
:exc:`TypeError`.
124124

@@ -201,13 +201,13 @@ Basic Usage
201201

202202
.. function:: loads(s, encoding=None, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw)
203203

204-
Deserialize *s* (a :class:`str` or :class:`unicode` instance containing a JSON
204+
Deserialize *s* (a :class:`bytes` or :class:`str` instance containing a JSON
205205
document) to a Python object.
206206

207-
If *s* is a :class:`str` instance and is encoded with an ASCII based encoding
207+
If *s* is a :class:`bytes` instance and is encoded with an ASCII based encoding
208208
other than UTF-8 (e.g. latin-1), then an appropriate *encoding* name must be
209209
specified. Encodings that are not ASCII based (such as UCS-2) are not
210-
allowed and should be decoded to :class:`unicode` first.
210+
allowed and should be decoded to :class:`str` first.
211211

212212
The other arguments have the same meaning as in :func:`dump`.
213213

Doc/library/multiprocessing.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,14 @@ To show the individual process IDs involved, here is an expanded example::
7777
import os
7878

7979
def info(title):
80-
print title
81-
print 'module name:', __name__
82-
print 'parent process:', os.getppid()
83-
print 'process id:', os.getpid()
80+
print(title)
81+
print('module name:', __name__)
82+
print('parent process:', os.getppid())
83+
print('process id:', os.getpid())
8484

8585
def f(name):
8686
info('function f')
87-
print 'hello', name
87+
print('hello', name)
8888

8989
if __name__ == '__main__':
9090
info('main line')
@@ -279,10 +279,10 @@ For example::
279279
return x*x
280280

281281
if __name__ == '__main__':
282-
pool = Pool(processes=4) # start 4 worker processes
282+
pool = Pool(processes=4) # start 4 worker processes
283283
result = pool.apply_async(f, [10]) # evaluate "f(10)" asynchronously
284-
print result.get(timeout=1) # prints "100" unless your computer is *very* slow
285-
print pool.map(f, range(10)) # prints "[0, 1, 4,..., 81]"
284+
print(result.get(timeout=1)) # prints "100" unless your computer is *very* slow
285+
print(pool.map(f, range(10))) # prints "[0, 1, 4,..., 81]"
286286

287287

288288
Reference

Doc/library/plistlib.rst

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ top level object is a dictionary.
2020

2121
Values can be strings, integers, floats, booleans, tuples, lists, dictionaries
2222
(but only with string keys), :class:`Data` or :class:`datetime.datetime`
23-
objects. String values (including dictionary keys) may be unicode strings --
23+
objects. String values (including dictionary keys) has to be unicode strings --
2424
they will be written out as UTF-8.
2525

2626
The ``<data>`` plist type is supported through the :class:`Data` class. This is
@@ -83,22 +83,20 @@ Examples
8383
Generating a plist::
8484

8585
pl = dict(
86-
aString="Doodah",
87-
aList=["A", "B", 12, 32.1, [1, 2, 3]],
86+
aString = "Doodah",
87+
aList = ["A", "B", 12, 32.1, [1, 2, 3]],
8888
aFloat = 0.1,
8989
anInt = 728,
90-
aDict=dict(
91-
anotherString="<hello & hi there!>",
92-
aUnicodeValue=u'M\xe4ssig, Ma\xdf',
93-
aTrueValue=True,
94-
aFalseValue=False,
90+
aDict = dict(
91+
anotherString = "<hello & hi there!>",
92+
aThirdString = "M\xe4ssig, Ma\xdf",
93+
aTrueValue = True,
94+
aFalseValue = False,
9595
),
9696
someData = Data("<binary gunk>"),
9797
someMoreData = Data("<lots of binary gunk>" * 10),
9898
aDate = datetime.datetime.fromtimestamp(time.mktime(time.gmtime())),
9999
)
100-
# unicode keys are possible, but a little awkward to use:
101-
pl[u'\xc5benraa'] = "That was a unicode key."
102100
writePlist(pl, fileName)
103101

104102
Parsing a plist::

Doc/library/ssl.rst

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -311,12 +311,12 @@ SSLSocket Objects
311311
name-value pairs::
312312

313313
{'notAfter': 'Feb 16 16:54:50 2013 GMT',
314-
'subject': ((('countryName', u'US'),),
315-
(('stateOrProvinceName', u'Delaware'),),
316-
(('localityName', u'Wilmington'),),
317-
(('organizationName', u'Python Software Foundation'),),
318-
(('organizationalUnitName', u'SSL'),),
319-
(('commonName', u'somemachine.python.org'),))}
314+
'subject': ((('countryName', 'US'),),
315+
(('stateOrProvinceName', 'Delaware'),),
316+
(('localityName', 'Wilmington'),),
317+
(('organizationName', 'Python Software Foundation'),),
318+
(('organizationalUnitName', 'SSL'),),
319+
(('commonName', 'somemachine.python.org'),))}
320320

321321
If the ``binary_form`` parameter is :const:`True`, and a
322322
certificate was provided, this method returns the DER-encoded form
@@ -522,20 +522,20 @@ As of September 6, 2007, the certificate printed by this program
522522
looked like this::
523523

524524
{'notAfter': 'May 8 23:59:59 2009 GMT',
525-
'subject': ((('serialNumber', u'2497886'),),
526-
(('1.3.6.1.4.1.311.60.2.1.3', u'US'),),
527-
(('1.3.6.1.4.1.311.60.2.1.2', u'Delaware'),),
528-
(('countryName', u'US'),),
529-
(('postalCode', u'94043'),),
530-
(('stateOrProvinceName', u'California'),),
531-
(('localityName', u'Mountain View'),),
532-
(('streetAddress', u'487 East Middlefield Road'),),
533-
(('organizationName', u'VeriSign, Inc.'),),
525+
'subject': ((('serialNumber', '2497886'),),
526+
(('1.3.6.1.4.1.311.60.2.1.3', 'US'),),
527+
(('1.3.6.1.4.1.311.60.2.1.2', 'Delaware'),),
528+
(('countryName', 'US'),),
529+
(('postalCode', '94043'),),
530+
(('stateOrProvinceName', 'California'),),
531+
(('localityName', 'Mountain View'),),
532+
(('streetAddress', '487 East Middlefield Road'),),
533+
(('organizationName', 'VeriSign, Inc.'),),
534534
(('organizationalUnitName',
535-
u'Production Security Services'),),
535+
'Production Security Services'),),
536536
(('organizationalUnitName',
537-
u'Terms of use at www.verisign.com/rpa (c)06'),),
538-
(('commonName', u'www.verisign.com'),))}
537+
'Terms of use at www.verisign.com/rpa (c)06'),),
538+
(('commonName', 'www.verisign.com'),))}
539539

540540
which is a fairly poorly-formed ``subject`` field.
541541

Doc/library/subprocess.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,13 +510,13 @@ Return code handling translates as follows::
510510
...
511511
rc = pipe.close()
512512
if rc != None and rc % 256:
513-
print "There were some errors"
513+
print("There were some errors")
514514
==>
515515
process = Popen(cmd, 'w', stdin=PIPE)
516516
...
517517
process.stdin.close()
518518
if process.wait() != 0:
519-
print "There were some errors"
519+
print("There were some errors")
520520

521521

522522
Replacing functions from the :mod:`popen2` module

Doc/library/tkinter.ttk.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1228,7 +1228,7 @@ option. If you don't know the class name of a widget, use the method
12281228

12291229
from tkinter import ttk
12301230

1231-
print ttk.Style().lookup("TButton", "font")
1231+
print(ttk.Style().lookup("TButton", "font"))
12321232

12331233

12341234
.. method:: layout(style[, layoutspec=None])

Doc/library/turtle.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ Tell Turtle's state
645645
>>> turtle.forward(100)
646646
>>> turtle.pos()
647647
(64.28,76.60)
648-
>>> print turtle.xcor()
648+
>>> print(turtle.xcor())
649649
64.2787609687
650650

651651

@@ -658,9 +658,9 @@ Tell Turtle's state
658658
>>> turtle.home()
659659
>>> turtle.left(60)
660660
>>> turtle.forward(100)
661-
>>> print turtle.pos()
661+
>>> print(turtle.pos())
662662
(50.00,86.60)
663-
>>> print turtle.ycor()
663+
>>> print(turtle.ycor())
664664
86.6025403784
665665

666666

Doc/library/unicodedata.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ Examples:
146146

147147
>>> import unicodedata
148148
>>> unicodedata.lookup('LEFT CURLY BRACKET')
149-
u'{'
149+
'{'
150150
>>> unicodedata.name('/')
151151
'SOLIDUS'
152152
>>> unicodedata.decimal('9')

Doc/library/winreg.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,12 @@ This module offers the following functions:
130130
+-------+--------------------------------------------+
131131

132132

133-
.. function:: ExpandEnvironmentStrings(unicode)
133+
.. function:: ExpandEnvironmentStrings(str)
134134

135-
Expands environment strings %NAME% in unicode string like const:`REG_EXPAND_SZ`::
135+
Expands environment strings %NAME% in unicode string like :const:`REG_EXPAND_SZ`::
136136

137-
>>> ExpandEnvironmentStrings(u"%windir%")
138-
u"C:\\Windows"
137+
>>> ExpandEnvironmentStrings('%windir%')
138+
'C:\\Windows'
139139

140140

141141
.. function:: FlushKey(key)

0 commit comments

Comments
 (0)
0