True

Terry Reedy tjreedy at udel.edu
Thu Aug 7 12:56:04 EDT 2003


"Daniel Klein" <danielk at aracnet.com> wrote in message
news:vrh4jvopu29elj8fu26upnf48f45de22h9 at 4ax.com...

> On Wed, 06 Aug 2003 12:18:45 -0400, Peter Hansen <peter at engcorp.com>
> wrote:
> >def boolean2String(boolVal):
> >  return { False : '1', True : '0' } [ not boolVal ]

> Thanks Peter, that will do the trick. Just  wondering though why you
> chose to code the opposite values and not as
>
> def boolean2String(boolVal):
>     return {True:'1', False:'0'}[boolVal]

Your function requires the arg to be 0/1 (True/False).  Peter's
function works for *any* input that can be 'not'ed.

TJR






More information about the Python-list mailing list