annotate Lib/types.py @ 5817:48b94de85bf3 legacy-trunk

Extensive changes by AMK.
author Guido van Rossum <guido@python.org>
date Thu, 17 Jul 1997 16:29:42 +0000
parents 3b3f7c3f6da2
children 24845968323f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1680
0a60460e99f0 Two new generally useful modules: types defines names for all built-in types,
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 # Define names for all type symbols known in the standard interpreter.
0a60460e99f0 Two new generally useful modules: types defines names for all built-in types,
Guido van Rossum <guido@python.org>
parents:
diff changeset
2 # Types that are part of optional modules (e.g. array) are not listed.
0a60460e99f0 Two new generally useful modules: types defines names for all built-in types,
Guido van Rossum <guido@python.org>
parents:
diff changeset
3
0a60460e99f0 Two new generally useful modules: types defines names for all built-in types,
Guido van Rossum <guido@python.org>
parents:
diff changeset
4 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
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 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
7 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
8
0a60460e99f0 Two new generally useful modules: types defines names for all built-in types,
Guido van Rossum <guido@python.org>
parents:
diff changeset
9 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
10 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
11 FloatType = type(0.0)
3385
d5532a71b454 better way to define ComplexType
Guido van Rossum <guido@python.org>
parents: 3351
diff changeset
12 try:
3351
ae004a45050f add ComplexType
Guido van Rossum <guido@python.org>
parents: 2438
diff changeset
13 ComplexType = type(complex(0,1))
3385
d5532a71b454 better way to define ComplexType
Guido van Rossum <guido@python.org>
parents: 3351
diff changeset
14 except NameError:
d5532a71b454 better way to define ComplexType
Guido van Rossum <guido@python.org>
parents: 3351
diff changeset
15 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
16
0a60460e99f0 Two new generally useful modules: types defines names for all built-in types,
Guido van Rossum <guido@python.org>
parents:
diff changeset
17 StringType = type('')
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 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
20 ListType = type([])
2438
1f59f2a13312 added DictType as alias for DictionaryType
Guido van Rossum <guido@python.org>
parents: 1917
diff changeset
21 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
22
1917
014a1fb9c646 Cosmetic changes
Guido van Rossum <guido@python.org>
parents: 1680
diff changeset
23 def _f(): pass
014a1fb9c646 Cosmetic changes
Guido van Rossum <guido@python.org>
parents: 1680
diff changeset
24 FunctionType = type(_f)
014a1fb9c646 Cosmetic changes
Guido van Rossum <guido@python.org>
parents: 1680
diff changeset
25 LambdaType = type(lambda: None) # Same as FunctionType
014a1fb9c646 Cosmetic changes
Guido van Rossum <guido@python.org>
parents: 1680
diff changeset
26 CodeType = type(_f.func_code)
1680
0a60460e99f0 Two new generally useful modules: types defines names for all built-in types,
Guido van Rossum <guido@python.org>
parents:
diff changeset
27
1917
014a1fb9c646 Cosmetic changes
Guido van Rossum <guido@python.org>
parents: 1680
diff changeset
28 class _C:
014a1fb9c646 Cosmetic changes
Guido van Rossum <guido@python.org>
parents: 1680
diff changeset
29 def _m(self): pass
014a1fb9c646 Cosmetic changes
Guido van Rossum <guido@python.org>
parents: 1680
diff changeset
30 ClassType = type(_C)
014a1fb9c646 Cosmetic changes
Guido van Rossum <guido@python.org>
parents: 1680
diff changeset
31 UnboundMethodType = type(_C._m) # Same as MethodType
014a1fb9c646 Cosmetic changes
Guido van Rossum <guido@python.org>
parents: 1680
diff changeset
32 _x = _C()
014a1fb9c646 Cosmetic changes
Guido van Rossum <guido@python.org>
parents: 1680
diff changeset
33 InstanceType = type(_x)
014a1fb9c646 Cosmetic changes
Guido van Rossum <guido@python.org>
parents: 1680
diff changeset
34 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
35
1917
014a1fb9c646 Cosmetic changes
Guido van Rossum <guido@python.org>
parents: 1680
diff changeset
36 BuiltinFunctionType = type(len)
014a1fb9c646 Cosmetic changes
Guido van Rossum <guido@python.org>
parents: 1680
diff changeset
37 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
38
0a60460e99f0 Two new generally useful modules: types defines names for all built-in types,
Guido van Rossum <guido@python.org>
parents:
diff changeset
39 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
40
1917
014a1fb9c646 Cosmetic changes
Guido van Rossum <guido@python.org>
parents: 1680
diff changeset
41 FileType = type(sys.stdin) # XXX what if it was assigned to?
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 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
43
0a60460e99f0 Two new generally useful modules: types defines names for all built-in types,
Guido van Rossum <guido@python.org>
parents:
diff changeset
44 try:
0a60460e99f0 Two new generally useful modules: types defines names for all built-in types,
Guido van Rossum <guido@python.org>
parents:
diff changeset
45 raise TypeError
0a60460e99f0 Two new generally useful modules: types defines names for all built-in types,
Guido van Rossum <guido@python.org>
parents:
diff changeset
46 except TypeError:
0a60460e99f0 Two new generally useful modules: types defines names for all built-in types,
Guido van Rossum <guido@python.org>
parents:
diff changeset
47 TracebackType = type(sys.exc_traceback)
0a60460e99f0 Two new generally useful modules: types defines names for all built-in types,
Guido van Rossum <guido@python.org>
parents:
diff changeset
48 FrameType = type(sys.exc_traceback.tb_frame)
0a60460e99f0 Two new generally useful modules: types defines names for all built-in types,
Guido van Rossum <guido@python.org>
parents:
diff changeset
49
4402
1d275cd42c9b Added Slice and Ellipses types.
Guido van Rossum <guido@python.org>
parents: 3385
diff changeset
50 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
51 EllipsisType = type(Ellipsis)
4402
1d275cd42c9b Added Slice and Ellipses types.
Guido van Rossum <guido@python.org>
parents: 3385
diff changeset
52
1917
014a1fb9c646 Cosmetic changes
Guido van Rossum <guido@python.org>
parents: 1680
diff changeset
53 del sys, _f, _C, _x # Not for export