greg greg at
Thu Nov 13 08:28:26 CET 2008

Joe Strout wrote:
> This is not hypothetical -- just last week I had a hard-to-track-down  
> abend that ultimately turned out to be an NLTK.Tree object stored  
> someplace that I expected to only contain strings.  I found it by  
> littering my code with assertions of the form  
> isinstance(foo,basestring).

But you have to ask yourself whether the time taken to
write and maintain all these assertions is really
cost-effective. In my experience, occurrences like this
are actually extremely rare -- the vast majority of the
time, you do get a failure very quickly, and it's fairly
obvious from the traceback where to look for the problem.

It's as annoying as hell when something like this does
happen, but averaged over the lifetime of the project,
I find it doesn't cost all that much time.


More information about the Python-list mailing list