[Tutor] validation

Terry Carroll carroll at tjc.com
Mon Aug 27 23:48:28 CEST 2007


On Mon, 27 Aug 2007, Kent Johnson wrote:

> isinstance can take a tuple of types as its second argument....
> 
> Note that
>    isinstance(thing, (list, tuple))
> 
> and
>    type(thing) in [list, tuple]
> 
> are not equivalent. The first will be true for objects whose type is a 
> subclass of list and tuple while the second will not.

Thanks.  I totally missed that isinstance's second parameter can be a 
tuple.  That's a much better approach.

Wow, that makes two things I've learned today.  My brain is now full.




More information about the Tutor mailing list