which one is more efficient
Steven D'Aprano
steve at REMOVE-THIS-cybersource.com.au
Mon Feb 11 17:22:32 EST 2008
On Mon, 11 Feb 2008 10:41:44 -0500, Steve Holden wrote:
> If the "type" variable really is a type, of course, then the real
> solution is hardly radical: stop using the names of types and start
> using the types:
[snip example using "type(obj) in (type1, type2)"]
But if you're using actual types, you almost certainly want to allow for
subclasses as well:
isinstance(obj, tuple_of_types)
--
Steven
More information about the Python-list
mailing list