[Python-bugs-list] [ python-Bugs-652888 ] bad documentation for the "type" builtin
SourceForge.net
noreply@sourceforge.net
Fri, 10 Jan 2003 01:35:38 -0800
Bugs item #652888, was opened at 2002-12-12 15:36
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=652888&group_id=5470
Category: Documentation
Group: Python 2.2.2
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Michele Simionato (michele_s)
Assigned to: Nobody/Anonymous (nobody)
>Summary: bad documentation for the "type" builtin
Initial Comment:
After a discussion on comp.lang.python
http://groups.google.com/groups?dq=&hl=en&lr=&ie=UTF-8&threadm=7h38yyvgto8.fsf%40pc150.maths.bris.ac.uk&prev=/groups%3Fdq%3D%26num%3D25%26hl%3Den%26lr%3D%26ie%3DUTF-8%26group%3Dcomp.lang.python%26start%3D0
I was suggested to submit a bug report about the
documentation of the
built-in "type". The official 2.2.2 documentation says:
type(object)
Return the type of an object. The return value is
a type object.
The standard module types defines names for all
built-in types.
For instance:
>>> import types
>>> if type(x) == types.StringType: print
"It's a string"
This is misleading since the module types does not
contains all possible types,
for instance does not contain StaticMethodType (which I
was looking for).
Moreover, people pointed out much better idioms, like
>>> if type(x) is str: print "It's a
string"
or even (without using type)
>>> if isinstance(x, str): print "It's not
a moose!"
Moreover, I would be happy to see in the documentation
of the types
module a sentence about the alternative ways of
retrieving the type
of an object.
--
Michele Simionato - Dept. of Physics and Astronomy
210 Allen Hall Pittsburgh PA 15260 U.S.A.
Phone: 001-412-624-9041 Fax: 001-412-624-9163
Home-page: http://www.phyast.pitt.edu/~micheles/
----------------------------------------------------------------------
>Comment By: Raymond Hettinger (rhettinger)
Date: 2003-01-10 04:35
Message:
Logged In: YES
user_id=80475
Fixed.
See Doc/lib/libtypes.tex 1.55
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=652888&group_id=5470