[Types-sig] IsInstance
Paul Prescod
paul@prescod.net
Mon, 13 Dec 1999 22:22:31 -0800
Guido van Rossum wrote:
> Perhaps this could be an extension of isinstance()? (That already
> takes both class and type objects.)
I wanted the function to return an object:
myList=isinstance( foo, types.ListType )
if not myList:
myDict=isinstance( foo, types.DictionaryType )
Then we can do the inferencing by looking at a single statement. Compare
it to this:
if isinstance( foo, types.ListType ):
myList=foo
elif isinstance( foo, types.DictionaryType ):
myDict=foo
That inferencing is just too hard. It isn't a proper cast operator
anymore. If you are willing to change isinstance to return the object if
it matches then I would like to use it.
--
Paul Prescod - ISOGEN Consulting Engineer speaking for himself
Three things to be wary of: A new kid in his prime
A man who knows the answers, and code that runs first time
http://www.geezjan.org/humor/computers/threes.html