Implicit conversion to boolean in if and while statements
Devin Jeanpierre
jeanpierreda at gmail.com
Tue Jul 17 00:18:28 EDT 2012
On Mon, Jul 16, 2012 at 12:03 AM, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
> On Sun, 15 Jul 2012 22:15:13 -0400, Devin Jeanpierre wrote:
>
>> For example, instead of "if stack:" or "if bool(stack):", we could use
>> "if stack.isempty():". This line tells us explicitly that stack is a
>> container.
>
> isempty is not a container method.
Your entire reply is predicated on this idea that I was talking about
writing classes with this extra "isempty" method.
No. I was talking about having "isempty" be part of the collection
interface, and eliminating polymorphic bool conversion.
If you were confused, instead of assuming I meant something patently
absurd, you should have asked for a clarification.
-- Devin
More information about the Python-list
mailing list