Convert a sequence of bits to a bit-string

2007-12-15 Thread te509

Hi guys,
does anybody know how to convert a long
sequence of bits to a bit-string? I want to avoid this:

>>> bit=00110101110111010001
>>>  
>>> str(bit)
'949456129574336313917039111707606368434510426593532217946399871489'

I would appreciate a prompt reply because I have a python assessment to 
submit. 
Thanks, 
Thomas


-- 
http://mail.python.org/mailman/listinfo/python-list


Convert a sequence of bits to a bit-string

2007-12-15 Thread te509
Hi guys,
does anybody know how to convert a long
sequence of bits to a bit-string? I want to avoid this:

>>> bit=00110101110111010001
>>>  
>>> str(bit)
'949456129574336313917039111707606368434510426593532217946399871489'

I would appreciate a prompt reply because I have my python assessment to 
submit. Thanks, Thomas

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Convert a sequence of bits to a bit-string

2007-12-15 Thread te509

>> does anybody know how to convert a long
>> sequence of bits to a bit-string?
>
>Yes!
Would you like to help, please?

>> I would appreciate a prompt reply because I have a python assessment to
>> submit.
>
>Good luck, you're lucky you've got the whole weekend :)
That's not the only assignment I have to do...

>> Thanks,
>> Thomas
>
>HTH
I hope this is not like RTFM cause as much as I searched on the web I 
couldn't find an answer.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Convert a sequence of bits to a bit-string

2007-12-15 Thread te509
First of all I'd like to thank you all for your advices. Before I check all 
your hints I want to clarify what I'm trying to do. The question says 
"write a function that takes a sequence of bits as an input and return how 
many 1s are in the sequence", nothing more. This is quite simple for string 
inputs but tricky for "number inputs". I've notice that if I try to convert 
a number starting with 0 to a string using str(), then I take a string 
representing another number (probably converted to decimal). So what I want 
to do is to write a generic version of a function that takes as an input a 
sequence of 1s and 0s in any format. The only way I can think to achieve 
that is by converting the "number inputs" to a string and then using the 
count() function. Thomas

-- 
http://mail.python.org/mailman/listinfo/python-list