[Tutor] Defining "bit" type
W W
srilyk at gmail.com
Sat Jan 24 16:55:06 CET 2009
On Sat, Jan 24, 2009 at 9:38 AM, Vicent <vginer at gmail.com> wrote:
> <snip>
>> So, maybe I can adapt the definition of "bool" type, I don't know...
>> Anyway, I want to manage 0's and 1's, not "Falses" and "Trues".<snip>
>>
>
Well, I can think of something that might be of some help:
In [18]: bit = {True:1, False:0}
In [19]: bit[True]
Out[19]: 1
In [20]: bit[False]
Out[20]: 0
In [21]: bit
Out[21]: {False: 0, True: 1}
In [22]: x = False
In [23]: bit[x]
Out[23]: 0
That might give you something to work with. Anyway, HTH,
Wayne
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090124/20afa296/attachment.htm>
More information about the Tutor
mailing list