programming logical functions: myand, myor and mynot

Jeff Shannon jeff at
Mon Nov 19 21:07:46 CET 2001

Gernot wrote:

> "Jeff Shannon" <jeff at> schrieb im Newsbeitrag
> news:3BF429F1.146759EA at
> >
> > Gernot wrote:
> [deleted]
> > > module which i have to "activate" first??
> >
> > There is no bool() in Python.  You'll have to build your own.
> > But at least you've got a decent start on your homework.
> You are right, i mixed it up with something different. Thanks for your
> comment.

Actually, it's even more simple than you think, in Python.

def bool(x):
    if x:
        return 1
        return 0

Or, alternatively

import operator

def bool(x):
    return operator.truth(x)

Jeff Shannon
Credit International

More information about the Python-list mailing list