Boolean tests [was Re: Attack a sacred Python Cow]
castironpi
castironpi at gmail.com
Wed Jul 30 22:26:05 EDT 2008
On Jul 30, 1:50 am, Carl Banks <pavlovevide... at gmail.com> wrote:
> On Jul 30, 1:58 am, "Russ P." <Russ.Paie... at gmail.com> wrote:
>
>
>
> > On Jul 29, 10:33 pm, Carl Banks <pavlovevide... at gmail.com> wrote:
>
> > > On Jul 30, 1:15 am, "Russ P." <Russ.Paie... at gmail.com> wrote:
> > > > Having said that, it would sure be nice to be able to write
>
> > > > if myList is not empty:
>
> > > > instead of
>
> > > > if len(myList) != 0:
>
> > > I can agree with this.
>
> > But I guess that could only work if there were only one empty list
> > that represents all empty lists (as there is only one actual "None").
> > I don't know if that makes sense or not.
>
> I mean in general. I wouldn't spell it like that. I would prefer if
> empty(x), with an __empty__ method. (And support __nonzero__ aka
> __bool__ dropped completely.)
>
> Carl Banks
An __empty__ method could return True for my social life, ha ha. Does
__nonzero__ just mean __nonempty__?
More information about the Python-list
mailing list