Re: Ascii to binary conversion

2008-08-09 Thread Terry Reedy
azrael wrote: Any idea how to easily write a function that recieves a character or string and returns a binary number like: ascii("1") is converted to bin("00110001") Other alternatives in 2.6 (I believe) and 3.0: >>> 0b00111010101 469 >>> b='111010101' >>> eval('0b'+b) 469 >>> '{0:b}'.forma

Re: Ascii to binary conversion

2008-08-09 Thread John Machin
On Aug 10, 12:37 am, azrael <[EMAIL PROTECTED]> wrote: [top-posting corrected] > > On 9 kol, 15:39, John Machin <[EMAIL PROTECTED]> wrote: > > > On Aug 9, 11:18 pm, azrael <[EMAIL PROTECTED]> wrote: > > > > Hy folks, > > > > I googled, and searched, and can not bealive that I have not found a > > >

Re: Ascii to binary conversion

2008-08-09 Thread azrael
You see, I don't like reading some tutorials. I pick myself a problem and look for ways to slove it. I am using Python for about 2 years, but mostly for image processing. As you say, ord is oposite to chr. I learn by example. thnx guys, this looks great On 9 kol, 16:47, Larry Bates <[EMAIL PROTE

Re: Ascii to binary conversion

2008-08-09 Thread Mensanator
On Aug 9, 8:18�am, azrael <[EMAIL PROTECTED]> wrote: > Hy folks, > > I googled, and searched, and can not bealive that I have not found a > built in way to convert the easy and elegant python way a function to > easily convert simple ascii data to binary and back. > > I've written some my own but t

Re: Ascii to binary conversion

2008-08-09 Thread Larry Bates
azrael wrote: looks nice. is there an oposite function of ord() so I could also bring a binary number also back to ascii. the speed matters if you plan to exchange about 10 M ascii chars and don't wont to wait a year for the results. :) On 9 kol, 15:39, John Machin <[EMAIL PROTECTED]> wrote:

Re: Ascii to binary conversion

2008-08-09 Thread azrael
looks nice. is there an oposite function of ord() so I could also bring a binary number also back to ascii. the speed matters if you plan to exchange about 10 M ascii chars and don't wont to wait a year for the results. :) On 9 kol, 15:39, John Machin <[EMAIL PROTECTED]> wrote: > On Aug 9, 11:1

Re: Ascii to binary conversion

2008-08-09 Thread John Machin
On Aug 9, 11:18 pm, azrael <[EMAIL PROTECTED]> wrote: > Hy folks, > > I googled, and searched, and can not bealive that I have not found a > built in way to convert the easy and elegant python way a function to > easily convert simple ascii data to binary and back. > > I've written some my own but

Ascii to binary conversion

2008-08-09 Thread azrael
Hy folks, I googled, and searched, and can not bealive that I have not found a built in way to convert the easy and elegant python way a function to easily convert simple ascii data to binary and back. I've written some my own but they were pretty slow using binascii linbrary with hexifly and unh