Is 'isinstance()' the right thing?

Delaney, Timothy tdelaney at avaya.com
Tue Apr 30 20:24:00 EDT 2002


> From: Ralf Juengling [mailto:juenglin at informatik.uni-freiburg.de]
> 
> Erik Max Francis <max at alcyone.com> writes:
> 
> > Ralf Juengling wrote:
> > 
> > > So, what is the proper, 'pythonic' way of argument checking?
> > 
> > The "Pythonic" way of argument checking is to simply use it 
> and catch
> > the exceptions that will be thrown if it doesn't behave as planned.
> 
> Hm, you might risk to destroy something this way (i.e. when 
> an exception
> occurs to late). 

Perhaps - but you also have the same problem if something implements an
interface, but doesn't adhere to the contract that is stated for that
interface.

Your unit tests should catch these problems.

Tim Delaney





More information about the Python-list mailing list