Re: [Tutor] Conversion question

2009-06-16 Thread Lie Ryan
Tom Green wrote: > Correct 8-bit ASCII. Sorry about that. I am using Python 2.5.2, which > doesn't support bin. If I upgraded how would I go about converting the > entire string to 8-bit ASCII? > AFAIK, earlier versions of python does not have a function/module that converts a number to its bi

Re: [Tutor] Conversion question

2009-06-16 Thread Tom Green
Thanks I just happened to find the site myself. I guess I have to pass each character to the function and build the 8-bit ASCII string or is there a better way to do it? On Tue, Jun 16, 2009 at 3:37 PM, Wayne wrote: > On Tue, Jun 16, 2009 at 2:25 PM, Tom Green wrote: > >> Correct 8-bit ASCII.

Re: [Tutor] Conversion question

2009-06-16 Thread Wayne
On Tue, Jun 16, 2009 at 2:25 PM, Tom Green wrote: > Correct 8-bit ASCII. Sorry about that. I am using Python 2.5.2, which > doesn't support bin. If I upgraded how would I go about converting the > entire string to 8-bit ASCII? > > I appreciate your help. you write the conversion yourself.

Re: [Tutor] Conversion question

2009-06-16 Thread Tom Green
Correct 8-bit ASCII. Sorry about that. I am using Python 2.5.2, which doesn't support bin. If I upgraded how would I go about converting the entire string to 8-bit ASCII? I appreciate your help. On Tue, Jun 16, 2009 at 3:05 PM, Lie Ryan wrote: > xchime...@gmail.com wrote: > > Thanks for th

Re: [Tutor] Conversion question

2009-06-16 Thread Lie Ryan
xchime...@gmail.com wrote: > Thanks for the reply I would like to print the string in binary > Man=01001101011101101110 > What's M in binary? Nobody knows... What's M in encoded in 8-bit ASCII string: '0b1001101' Source: bin(ord('M')) ___ Tutor ma

Re: [Tutor] Conversion question

2009-06-16 Thread xchimeras
Thanks for the reply I would like to print the string in binary Man=01001101011101101110 Sent from my Verizon Wireless BlackBerry -Original Message- From: Wayne Date: Tue, 16 Jun 2009 13:13:58 To: Cc: Subject: Re: [Tutor] Conversion question On Tue, Jun 16, 2009 at 12:46 PM

Re: [Tutor] Conversion question

2009-06-16 Thread Wayne
On Tue, Jun 16, 2009 at 12:46 PM, wrote: > Quick question. Say I have a string a="Man" and I want to print the string > in base2. Is there a python function like there is in perl to do this? > Thanks in advance for any input do you mean like this: In [23]: int('Man', 2)

Re: [Tutor] Conversion question

2009-05-05 Thread Tom Green
Thanks everyone for your replies. This reason for the long string is sometimes I have to pass a 32 byte key (MD5 hash value) to the socket. The data I am sending is the hex values i.e. 41=A. I believe the binascii will work. Mike On Mon, May 4, 2009 at 7:52 PM, Alan Gauld wrote: > > "Tom Gree

Re: [Tutor] Conversion question

2009-05-05 Thread Alan Gauld
"Emile van Sebille" wrote "414243440d0a" Is there a way in Python to say this is a string of HEX characters like Perl's pack? Right now I have to take the string and add a \x to every two values i.e. \x41\x42... import binascii binascii.a2b_hex('41424344') I hadn't come across binascii

Re: [Tutor] Conversion question

2009-05-05 Thread spir
Le Tue, 5 May 2009 00:52:11 +0100, "Alan Gauld" s'exprima ainsi: > > Is there a way in Python to say this is a string of HEX characters like > > Perl's pack? Right now I have to take the string and add a \x to every > > two > > values i.e. \x41\x42... > > Assuming you actually want to send t

Re: [Tutor] Conversion question

2009-05-04 Thread Alan Gauld
"Tom Green" wrote Here is my question. I work with a lot of sockets and most of them require hex data. I am usually given a string of data to send to the socket. Example: "414243440d0a" Is there a way in Python to say this is a string of HEX characters like Perl's pack? Right now I have

Re: [Tutor] Conversion question

2009-05-04 Thread Tom Green
Thank you, I didn't realize it was that easy. I tried binascii before and I thought it didn't work properly. I appreciate it. Mike. On Mon, May 4, 2009 at 7:40 PM, Emile van Sebille wrote: > On 5/4/2009 4:17 PM Tom Green said... > >> First, thanks in advance for any insight on how to assist i

Re: [Tutor] Conversion question

2009-05-04 Thread Emile van Sebille
On 5/4/2009 4:17 PM Tom Green said... First, thanks in advance for any insight on how to assist in making me a better Python programmer. Here is my question. I work with a lot of sockets and most of them require hex data. I am usually given a string of data to send to the socket. Example: