typechecks: just say no! (was Re: Determining Types)

Alex Martelli aleax at aleax.it
Mon Sep 3 11:24:35 EDT 2001


"Skip Montanaro" <skip at pobox.com> wrote in message
news:mailman.999528483.6865.python-list at python.org...
>
> One place that I've actually found typechecking useful is at the boundary
of
> my XML-RPC server.  If I'm expecting a string input (say, the name of a
> band) and someone on the other side inputs "311" to a Perl-based website
> which then passes the query to my server, I get an integer that I have to
> coerce back to a string.  In my comments I call it a "Perl guard". ;-)

So why not just use str(whateverthingyyouget) [or the Unicode
equivalent if Unicode is what you need]?  Beats going around
with "if type..." (or even "if isinstance..."), IMHO.

[BTW, you'll probably be out of luck if somebody needs a
band called "0800" -- you'll get some octalized thing, yes?-)]


Alex






More information about the Python-list mailing list