[Tutor] type objects - 2nd try

Karl Pflästerer sigurd at 12move.de
Sat Aug 16 00:59:00 EDT 2003


On 15 Aug 2003, Gregor Lingl <- glingl at aon.at wrote:

[...]

> 3. QUESTION
> (1) Are there named type-objects for functions, generators, classes
> and the like, in order to determine the type of functions, generators etc.
> more easily, i. e. not to need to define a "prototype"-object first.
> If so, what are their names?

$ python
Python 2.3 (#1, Aug  1 2003, 15:01:23) 
[GCC 3.2 20020927 (prerelease)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import types
>>> def f():
...     pass
... 
>>> type(f) == types.FunctionType
True
>>> dir(types)
['BooleanType', 'BufferType', 'BuiltinFunctionType', 'BuiltinMethodType', 'ClassType', 'CodeType', 'ComplexType', 'DictProxyType', 'DictType', 'DictionaryType', 'EllipsisType', 'FileType', 'FloatType', 'FrameType', 'FunctionType', 'GeneratorType', 'InstanceType', 'IntType', 'LambdaType', 'ListType', 'LongType', 'MethodType', 'ModuleType', 'NoneType', 'NotImplementedType', 'ObjectType', 'SliceType', 'StringType', 'StringTypes', 'TracebackType', 'TupleType', 'TypeType', 'UnboundMethodType', 'UnicodeType', 'XRangeType', '__builtins__', '__doc__', '__file__', '__name__']
>>> 


> (2) Where can I find an in-depth - albei easily to read - discussion
> of "type-objects", especially if there are different types of types
> ("All types are equal, but some are more equal ?)

Did you look in the Python language reference?  The node is numbered 3.2
`The standard type hierarchy'.  The file is
/path_to_your_python_docs/html/ref/types.html 



   Karl
-- 
Please do *not* send copies of replies to me.
I read the list




More information about the Tutor mailing list