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

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


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

Category: Documentation
Group: None
Status: Open
Resolution: None
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 

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

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