This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: bad documentation for the "type" builtin
Type: Stage:
Components: Documentation Versions: Python 2.2
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: michele_s, rhettinger
Priority: normal Keywords:

Created on 2002-12-12 20:36 by michele_s, last changed 2022-04-10 16:06 by admin. This issue is now closed.

Messages (2)
msg13602 - (view) Author: Michele Simionato (michele_s) Date: 2002-12-12 20:36
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/
msg13603 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2003-01-10 09:35
Logged In: YES 
user_id=80475

Fixed.
See Doc/lib/libtypes.tex 1.55
History
Date User Action Args
2022-04-10 16:06:00adminsetgithub: 37607
2002-12-12 20:36:23michele_screate