Just good advice? = WAS("Re: getting system date")

Terry Reedy tjreedy at udel.edu
Mon May 12 01:21:50 EDT 2003


"David Broadwell" <anti-spam.dbroadwell at mindspring.com> wrote in
message news:u2zva.4890$Ur1.3812 at nwrddc03.gnilink.net...
> From what you hinted at, i'll leave in my 'paranioa' tests in many
of my
> routines that test things that the computer will never make a
mistake on,
> but that i might.
>
> def zoobar(somelist):
>     ''' Takes a list an complains if it dosen't like it, might even
give it
> back '''
>     if somelist:
>         if type(somelist) == type([]): # paranoia type tests ... bad
coder,
> no biscut.
>             print "good list, put code here"
>             return somelist
>         else: print "zoobar requires list types not %s" %
type(somelist)
>     else: print "zoobar need argument ... a list would be good."
>
> So, question is; in the long run, are these kind of tests worth it?
> And; what kind are the best 'parnaoia' tests to do?

The question here is whether you *really* want to restrict the
function to accept lists and only lists rather than sequences or
iterables in general.

Terry J. Reedy






More information about the Python-list mailing list