__len__ and boolean values - small language change

Andrew Cooke andrew at andrewcooke.free-online.co.uk
Mon May 8 13:33:17 EDT 2000


In article <m366spt1x6.fsf at atrus.jesus.cam.ac.uk>,
  Michael Hudson <mwh21 at cam.ac.uk> wrote:
> Andrew Cooke <andrew at andrewcooke.free-online.co.uk> writes:
>
> [snip]
> > Is there a special method that I can override to provide boolean
values
> > in tests, or is __len__ called directly?
>
> You want __nonzero__:

excellent.  thanks v much.  on a meta-level it's also demonstrated to me
that the module index doesn't include entries for the language reference
;-)  sorry...

andrew


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list