typechecking (was Re: How to break out of two nested for loops?)

Kragen Sitaker kragen at pobox.com
Wed Jan 23 16:38:56 EST 2002


Laura Creighton <lac at strakt.com> writes:
> 'bad values' is the idea that I question.  Sticking  the try: 
> except AttributeError: around stuffToSpam =3D stuffToSpam.split() is only 
> a start.  Right now, I only know that spamThemAll works on strings
> because Michael Chermside said so.  But I want the gory details.
> Because the very first thing I want to do is the thing that was
> worrying him -- pass a not-string-or-list to spamThemAll.  I've
> already got a nice class library, full of lots of objects that need
> spamming.  I just need to find out what my objects need to do to be
> spammable.  Will UserStrings work?  What about 2.2 newclasses based on
> List and String?  Can I make them work with S=E9bastien Keim's fifos?
> (See:  http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/68436)
> 
> One extremely nice thing about using python is that you don't spend
> your mornings writing your 9,000th Design Pattern Adapter to get
> around the type system again.  Unless, of course, somebody has
> conscientiously added type-checking.  And of course, it is the
> best people, who are most prone to this -- the sloppy have never
> bothered checking their arguments.  Seems unfair if they get the
> last laugh on us all.

I mostly agree.  I just published something a few days ago entitled
"isinstance() considered harmful"; it's at 
http://lists.canonical.org/pipermail/kragen-tol/2002-January/000659.html

I've come up with some tools to make it easier to find out the answers
to the questions you ask about spamThemAll above --- what interface
does a particular package expect of its arguments?  They're almost
ready for prime time; a preliminary version is in the
very-unready-for-prime-time MetaPy package, which is at
http://pobox.com/~kragen/sw/MetaPy-7.tar.gz (also available as .zip,
.src.rpm, .noarch.rpm, and .win32.exe --- can you tell I've been using
distutils?  :)




More information about the Python-list mailing list