On Jul 29, 10:23 pm, Erik Max Francis <[EMAIL PROTECTED]> wrote: > Carl Banks wrote: > > Bzzt. "if len(x)!=0" is a simple explicit that would work for this > > class and all built-in containers. (Or should--Steven D'Aprano's > > objections notwithstanding, any reasonable container type should > > support this invariant. From a language design standpoint, an "empty" > > builtin could have been created to simplify this even more, but since > > there isn't one len(x)!=0 will have to do.) > > That you choose not to test for non-emptiness doesn't change the fact > that it's already a builtin part of the language that is supported by > all fundamental types and is overridable by anyone writing a custom > type. Use it or don't use it, but it's an example of precisely what you > were asking for that is both practical and already in widespread use.
That's not what I was asking for. I was asking for a use case for "if x" that can't be replaced by a simple explicit test. Your example didn't satisfy that. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list