Boolean tests [was Re: Attack a sacred Python Cow]

Carl Banks pavlovevidence at gmail.com
Mon Jul 28 16:22:37 EDT 2008


On Jul 28, 10:00 am, Steven D'Aprano <st... at REMOVE-THIS-
cybersource.com.au> wrote:
> Cutting to the crux of the discussion...
>
> On Sun, 27 Jul 2008 23:45:26 -0700, Carl Banks wrote:
> > I want something where "if x" will do but a simple explicit test won't.
>
> Explicit tests aren't simple unless you know what type x is. If x could
> be of any type, you can't write a simple test. Does x have a length? Is
> it a number? Maybe it's a fixed-length circular length, and the length is
> non-zero even when it's empty? Who knows? How many cases do you need to
> consider?

Use case, please.  I'm asking for code, not arguments.  Please give me
a piece of code where you can write "if x" that works but a simple
explicit test won't.

(Note: I'm not asking you to prove that "if len(x)!=0" might fail for
some contrived, poorly-realized class you could write.  I already know
you can do that.)


Carl Banks



More information about the Python-list mailing list