[Python-bugs-list] [ python-Bugs-632196 ] Use type(x) is ... instead of type(x) ==

noreply@sourceforge.net noreply@sourceforge.net
Fri, 01 Nov 2002 13:35:50 -0800


Bugs item #632196, was opened at 2002-11-01 13:50
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=632196&group_id=5470

Category: Documentation
Group: None
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Patrick K. O'Brien (pobrien)
Assigned to: Fred L. Drake, Jr. (fdrake)
Summary: Use type(x) is ... instead of type(x) ==

Initial Comment:
The sample code for type(object) should be: 
 
>>> if type(x) is types.StringType: print "It's a string" 
 
Instead of the older, deprecated idiom: 
 
>>> if type(x) == types.StringType: print "It's a string" 
 
This is the page I'm referencing: 
 
http://www.python.org/doc/current/lib/built-in-funcs.html#l2h-57 

----------------------------------------------------------------------

>Comment By: Fred L. Drake, Jr. (fdrake)
Date: 2002-11-01 16:35

Message:
Logged In: YES 
user_id=3066

Fixed, and added some additional clarifications, in
Doc/lib/libfuncs.tex revisions 1.119 and 1.100.4.13.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=632196&group_id=5470