summaryrefslogtreecommitdiffstats
path: root/Doc/c-api/abstract.rst
blob: 66426f72c3f0751707df2acc0ce1d15e2bbefa8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
.. highlightlang:: c

.. _abstract:

**********************
Abstract Objects Layer
**********************

The functions in this chapter interact with Python objects regardless of their
type, or with wide classes of object types (e.g. all numerical types, or all
sequence types).  When used on object types for which they do not apply, they
will raise a Python exception.

It is not possible to use these functions on objects that are not properly
initialized, such as a list object that has been created by :cfunc:`PyList_New`,
but whose items have not been set to some non-\ ``NULL`` value yet.

.. toctree::

   object.rst
   number.rst
   sequence.rst
   mapping.rst
   iter.rst
   objbuffer.rst
-git/cpython.git/snapshot/cpython-967f1e3b85ac239d6ae9900a62304392682131a7.zip'>cpython-967f1e3b85ac239d6ae9900a62304392682131a7.zip
cpython-967f1e3b85ac239d6ae9900a62304392682131a7.tar.gz
cpython-967f1e3b85ac239d6ae9900a62304392682131a7.tar.bz2
Remove string.{letters,lowercase,uppercase}.
Diffstat
-rw-r--r--Doc/lib/libstring.tex33
-rw-r--r--Lib/string.py9
-rw-r--r--Lib/test/test_csv.py2
-rw-r--r--Lib/test/test_pkgimport.py4
-rw-r--r--Lib/test/test_string.py6
-rw-r--r--Misc/NEWS3
-rwxr-xr-xTools/modulator/modulator.py4
-rwxr-xr-xTools/scripts/texi2html.py2
8 files changed, 17 insertions, 46 deletions
diff --git a/Doc/lib/libstring.tex b/Doc/lib/libstring.tex
index 055ac0c..9948cb7 100644
--- a/Doc/lib/libstring.tex
+++ b/Doc/lib/libstring.tex
@@ -13,18 +13,18 @@ functions based on regular expressions.
The constants defined in this module are:
-\begin{datadesc}{ascii_letters}
+\begin{datadesc}{ascii\_letters}
The concatenation of the \constant{ascii_lowercase} and
\constant{ascii_uppercase} constants described below. This value is
not locale-dependent.
\end{datadesc}
-\begin{datadesc}{ascii_lowercase}
+\begin{datadesc}{ascii\_lowercase}
The lowercase letters \code{'abcdefghijklmnopqrstuvwxyz'}. This
value is not locale-dependent and will not change.
\end{datadesc}
-\begin{datadesc}{ascii_uppercase}
+\begin{datadesc}{ascii\_uppercase}
The uppercase letters \code{'ABCDEFGHIJKLMNOPQRSTUVWXYZ'}. This
value is not locale-dependent and will not change.
\end{datadesc}
@@ -37,23 +37,6 @@ The constants defined in this module are:
The string \code{'0123456789abcdefABCDEF'}.
\end{datadesc}
-\begin{datadesc}{letters}
- The concatenation of the strings \constant{lowercase} and
- \constant{uppercase} described below. The specific value is
- locale-dependent, and will be updated when
- \function{locale.setlocale()} is called.
-\end{datadesc}
-
-\begin{datadesc}{lowercase}
- A string containing all the characters that are considered lowercase
- letters. On most systems this is the string
- \code{'abcdefghijklmnopqrstuvwxyz'}. Do not change its definition ---
- the effect on the routines \function{upper()} and
- \function{swapcase()} is undefined. The specific value is
- locale-dependent, and will be updated when
- \function{locale.setlocale()} is called.
-\end{datadesc}
-
\begin{datadesc}{octdigits}
The string \code{'01234567'}.
\end{datadesc}
@@ -69,16 +52,6 @@ The constants defined in this module are:
\constant{punctuation}, and \constant{whitespace}.
\end{datadesc}
-\begin{datadesc}{uppercase}
- A string containing all the characters that are considered uppercase
- letters. On most systems this is the string
- \code{'ABCDEFGHIJKLMNOPQRSTUVWXYZ'}. Do not change its definition ---
- the effect on the routines \function{lower()} and
- \function{swapcase()} is undefined. The specific value is
- locale-dependent, and will be updated when
- \function{locale.setlocale()} is called.
-\end{datadesc}
-
\begin{datadesc}{whitespace}
A string containing all characters that are considered whitespace.
On most systems this includes the characters space, tab, linefeed,
diff --git a/Lib/string.py b/Lib/string.py
index 51b2067..87073aa 100644
--- a/Lib/string.py
+++ b/Lib/string.py
@@ -16,17 +16,14 @@ printable -- a string containing all characters considered printable
# Some strings for ctype-style character classification
whitespace = ' \t\n\r\v\f'
-lowercase = 'abcdefghijklmnopqrstuvwxyz'
-uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
-letters = lowercase + uppercase
-ascii_lowercase = lowercase
-ascii_uppercase = uppercase
+ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
+ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_letters = ascii_lowercase + ascii_uppercase
digits = '0123456789'
hexdigits = digits + 'abcdef' + 'ABCDEF'
octdigits = '01234567'
punctuation = """!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~"""
-printable = digits + letters + punctuation + whitespace
+printable = digits + ascii_letters + punctuation + whitespace
# Case conversion helpers
# Use str to convert Unicode literal in case of -U
diff --git a/Lib/test/test_csv.py b/Lib/test/test_csv.py
index 21cc408..7ac52e3 100644
--- a/Lib/test/test_csv.py
+++ b/Lib/test/test_csv.py
@@ -645,7 +645,7 @@ class TestArrayWrites(unittest.TestCase):
def test_char_write(self):
import array, string
- a = array.array('u', string.letters)
+ a = array.array('u', string.ascii_letters)
with TemporaryFile("w+b") as fileobj:
writer = csv.writer(fileobj, dialect="excel")
diff --git a/Lib/test/test_pkgimport.py b/Lib/test/test_pkgimport.py
index 8b5e3ad..789f4d3 100644
--- a/Lib/test/test_pkgimport.py
+++ b/Lib/test/test_pkgimport.py
@@ -7,7 +7,7 @@ class TestImport(unittest.TestCase):
def __init__(self, *args, **kw):
self.package_name = 'PACKAGE_'
while self.package_name in sys.modules:
- self.package_name += random.choose(string.letters)
+ self.package_name += random.choose(string.ascii_letters)
self.module_name = self.package_name + '.foo'
unittest.TestCase.__init__(self, *args, **kw)
@@ -58,7 +58,7 @@ class TestImport(unittest.TestCase):
# ...make up a variable name that isn't bound in __builtins__
var = 'a'
while var in dir(__builtins__):
- var += random.choose(string.letters)
+ var += random.choose(string.ascii_letters)
# ...make a module that just contains that
self.rewrite_file(var)
diff --git a/Lib/test/test_string.py b/Lib/test/test_string.py