On Jul 31, 1:27 pm, "Chris Mellon" <[EMAIL PROTECTED]> wrote: > I'm really not sure where you're going with this or what you're trying > to prove. "if x" is a duck-type test for a boolean value. Obviously if > you know the type and want a more *specific* test, then you can use an > explicit one. Any time you don't know or don't care about a more > specific type than "something which probably is boolean true", or any > time where you know the boolean semantics of the type and want to drop > some typing, you can use "if x". The more specific test is what you'd > use if you want more specific results. What's complicated about this > idea?
Many people trumpet that "if x" makes your code more polymorphic whenever this comes up--in fact you just repeated the claim--without ever considering how rarely this more extensive polymorphism comes up in practice. I was calling them out to say "prove to me that it actually happens". I believe it's very rare not to know enough about the expected type that explicit tests won't work. We've uncovered a few examples of it in this thread, but IMO we haven't uncovered any sort of broad, wide- ranging use cases. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list