Mercurial > cpython-lru_cache-weakref
annotate Lib/types.py @ 17322:bd110eadc19a legacy-trunk
One-liner critical fix from Jim Fulton: Eric's string-method crusade
got the order backwards in a line (for .find()).
| author | Tim Peters <tim.peters@gmail.com> |
|---|---|
| date | Thu, 05 Apr 2001 22:26:23 +0000 |
| parents | 93dac4053189 |
| children | 9e326c9e6be5 |
| rev | line source |
|---|---|
|
11707
6f4146846337
The third and final doc-string sweep by Ka-Ping Yee.
Guido van Rossum <guido@python.org>
parents:
10429
diff
changeset
|
1 """Define names for all type symbols known in the standard interpreter. |
|
6f4146846337
The third and final doc-string sweep by Ka-Ping Yee.
Guido van Rossum <guido@python.org>
parents:
10429
diff
changeset
|
2 |
|
6f4146846337
The third and final doc-string sweep by Ka-Ping Yee.
Guido van Rossum <guido@python.org>
parents:
10429
diff
changeset
|
3 Types that are part of optional modules (e.g. array) are not listed. |
|
6f4146846337
The third and final doc-string sweep by Ka-Ping Yee.
Guido van Rossum <guido@python.org>
parents:
10429
diff
changeset
|
4 """ |
|
1680
0a60460e99f0
Two new generally useful modules: types defines names for all built-in types,
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
5 |
|
0a60460e99f0
Two new generally useful modules: types defines names for all built-in types,
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
6 import sys |
|
0a60460e99f0
Two new generally useful modules: types defines names for all built-in types,
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
7 |
|
0a60460e99f0
Two new generally useful modules: types defines names for all built-in types,
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
8 NoneType = type(None) |
|
0a60460e99f0
Two new generally useful modules: types defines names for all built-in types,
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
9 TypeType = type(NoneType) |
|
0a60460e99f0
Two new generally useful modules: types defines names for all built-in types,
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
10 |
|
0a60460e99f0
Two new generally useful modules: types defines names for all built-in types,
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
11 IntType = type(0) |
|
0a60460e99f0
Two new generally useful modules: types defines names for all built-in types,
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
12 LongType = type(0L) |
|
0a60460e99f0
Two new generally useful modules: types defines names for all built-in types,
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
13 FloatType = type(0.0) |
|
3385
d5532a71b454
better way to define ComplexType
Guido van Rossum <guido@python.org>
parents:
3351
diff
changeset
|
14 try: |
|
6235
24845968323f
Added some try-excepts so that it can be imported in restricted mode
Guido van Rossum <guido@python.org>
parents:
4403
diff
changeset
|
15 ComplexType = type(complex(0,1)) |
|
3385
d5532a71b454
better way to define ComplexType
Guido van Rossum <guido@python.org>
parents:
3351
diff
changeset
|
16 except NameError: |
|
6235
24845968323f
Added some try-excepts so that it can be imported in restricted mode
Guido van Rossum <guido@python.org>
parents:
4403
diff
changeset
|
17 pass |
|
1680
0a60460e99f0
Two new generally useful modules: types defines names for all built-in types,
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
18 |
|
0a60460e99f0
Two new generally useful modules: types defines names for all built-in types,
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
19 StringType = type('') |
|
11988
93dac4053189
Marc-Andre Lemburg: add UnicodeType.
Guido van Rossum <guido@python.org>
parents:
11707
diff
changeset
|
20 UnicodeType = type(u'') |
|
10429
f9ad148c980c
Added BufferType, the type returned by the new builtin buffer(). Greg Stein.
Guido van Rossum <guido@python.org>
parents:
9659
diff
changeset
|
21 BufferType = type(buffer('')) |
|
1680
0a60460e99f0
Two new generally useful modules: types defines names for all built-in types,
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
22 |
|
0a60460e99f0
Two new generally useful modules: types defines names for all built-in types,
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
23 TupleType = type(()) |
|
0a60460e99f0
Two new generally useful modules: types defines names for all built-in types,
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
24 ListType = type([]) |
|
2438
1f59f2a13312
added DictType as alias for DictionaryType
Guido van Rossum <guido@python.org>
parents:
1917
diff
changeset
|
25 DictType = DictionaryType = type({}) |
|
1680
0a60460e99f0
Two new generally useful modules: types defines names for all built-in types,
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
26 |
| 1917 | 27 def _f(): pass |
| 28 FunctionType = type(_f) | |
|
7755
fb4b4d069cc7
Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents:
6347
diff
changeset
|
29 LambdaType = type(lambda: None) # Same as FunctionType |
|
6235
24845968323f
Added some try-excepts so that it can be imported in restricted mode
Guido van Rossum <guido@python.org>
parents:
4403
diff
changeset
|
30 try: |
|
24845968323f
Added some try-excepts so that it can be imported in restricted mode
Guido van Rossum <guido@python.org>
parents:
4403
diff
changeset
|
31 CodeType = type(_f.func_code) |
|
24845968323f
Added some try-excepts so that it can be imported in restricted mode
Guido van Rossum <guido@python.org>
parents:
4403
diff
changeset
|
32 except: |
|
24845968323f
Added some try-excepts so that it can be imported in restricted mode
Guido van Rossum <guido@python.org>
parents:
4403
diff
changeset
|
33 pass |
|
1680
0a60460e99f0
Two new generally useful modules: types defines names for all built-in types,
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
34 |
| 1917 | 35 class _C: |
|
6235
24845968323f
Added some try-excepts so that it can be imported in restricted mode
Guido van Rossum <guido@python.org>
parents:
4403
diff
changeset
|
36 def _m(self): pass |
| 1917 | 37 ClassType = type(_C) |
|
7755
fb4b4d069cc7
Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents:
6347
diff
changeset
|
38 UnboundMethodType = type(_C._m) # Same as MethodType |
| 1917 | 39 _x = _C() |
| 40 InstanceType = type(_x) | |
| 41 MethodType = type(_x._m) | |
|
1680
0a60460e99f0
Two new generally useful modules: types defines names for all built-in types,
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
42 |
| 1917 | 43 BuiltinFunctionType = type(len) |
|
7755
fb4b4d069cc7
Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents:
6347
diff
changeset
|
44 BuiltinMethodType = type([].append) # Same as BuiltinFunctionType |
|
1680
0a60460e99f0
Two new generally useful modules: types defines names for all built-in types,
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
45 |
|
0a60460e99f0
Two new generally useful modules: types defines names for all built-in types,
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
46 ModuleType = type(sys) |
|
0a60460e99f0
Two new generally useful modules: types defines names for all built-in types,
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
47 |
|
6235
24845968323f
Added some try-excepts so that it can be imported in restricted mode
Guido van Rossum <guido@python.org>
parents:
4403
diff
changeset
|
48 try: |
|
9659
04b0a0f29f65
Use __stdin__ instead of stdin to derive FileType -- safer against
Guido van Rossum <guido@python.org>
parents:
7755
diff
changeset
|
49 FileType = type(sys.__stdin__) |
|
6235
24845968323f
Added some try-excepts so that it can be imported in restricted mode
Guido van Rossum <guido@python.org>
parents:
4403
diff
changeset
|
50 except: |
|
24845968323f
Added some try-excepts so that it can be imported in restricted mode
Guido van Rossum <guido@python.org>
parents:
4403
diff
changeset
|
51 pass |
|
1680
0a60460e99f0
Two new generally useful modules: types defines names for all built-in types,
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
52 XRangeType = type(xrange(0)) |
|
0a60460e99f0
Two new generally useful modules: types defines names for all built-in types,
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
53 |
|
0a60460e99f0
Two new generally useful modules: types defines names for all built-in types,
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
54 try: |
|
6235
24845968323f
Added some try-excepts so that it can be imported in restricted mode
Guido van Rossum <guido@python.org>
parents:
4403
diff
changeset
|
55 raise TypeError |
|
1680
0a60460e99f0
Two new generally useful modules: types defines names for all built-in types,
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
56 except TypeError: |
|
6235
24845968323f
Added some try-excepts so that it can be imported in restricted mode
Guido van Rossum <guido@python.org>
parents:
4403
diff
changeset
|
57 try: |
|
7755
fb4b4d069cc7
Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents:
6347
diff
changeset
|
58 tb = sys.exc_info()[2] |
|
fb4b4d069cc7
Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents:
6347
diff
changeset
|
59 TracebackType = type(tb) |
|
fb4b4d069cc7
Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents:
6347
diff
changeset
|
60 FrameType = type(tb.tb_frame) |
|
6235
24845968323f
Added some try-excepts so that it can be imported in restricted mode
Guido van Rossum <guido@python.org>
parents:
4403
diff
changeset
|
61 except: |
|
7755
fb4b4d069cc7
Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents:
6347
diff
changeset
|
62 pass |
|
6347
2656d1eea792
Use sys.exc_info() where needed.
Guido van Rossum <guido@python.org>
parents:
6235
diff
changeset
|
63 tb = None; del tb |
|
1680
0a60460e99f0
Two new generally useful modules: types defines names for all built-in types,
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
64 |
|
4402
1d275cd42c9b
Added Slice and Ellipses types.
Guido van Rossum <guido@python.org>
parents:
3385
diff
changeset
|
65 SliceType = type(slice(0)) |
|
4403
3b3f7c3f6da2
Ellipses -> Ellipsis rename (the dictionary really says that it should
Guido van Rossum <guido@python.org>
parents:
4402
diff
changeset
|
66 EllipsisType = type(Ellipsis) |
|
4402
1d275cd42c9b
Added Slice and Ellipses types.
Guido van Rossum <guido@python.org>
parents:
3385
diff
changeset
|
67 |
|
7755
fb4b4d069cc7
Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents:
6347
diff
changeset
|
68 del sys, _f, _C, _x # Not for export |
