[Tutor] string to binary and back... Python 3

Jordan wolfrage8765 at gmail.com
Thu Jul 19 20:37:14 CEST 2012



On 07/19/2012 08:14 AM, Mark Lawrence wrote:
> On 19/07/2012 06:41, wolfrage8765 at gmail.com wrote:
>> On Thu, Jul 19, 2012 at 12:16 AM, Dave Angel <d at davea.name> wrote:
>>
>
<SNIP>
> Really?  Are you using a forked version of Python that doesn't need
> indentation after a while loop, or are you speaking with a forked
> tongue? :)  Strangely I believe the latter, so please take note of
> what Dave Angel has told you and post with the correct indentation.
>
http://www.101emailetiquettetips.com/
Number 101 is for you. Good day.
>>
>>>
>>> I'd also recommend you remove a lot of the irrelevant details
>>> there.  if
>>> you have a problem with hexlfy and/or unhexlify, then give a simple
>>> byte
>>> string that doesn't work for you, and somebody can probably identify
>>> why
>>> not.  And if you want people to run your code, include the imports
>>> as well.
>>>
>>> My problem is not specific to hexlify and unhexlify, my problem is
>>> trying
>> to convert from string to binary and back. That is why all of the
>> details,
>> to show I have tried on my own.
>> Sorry that I forgot to include sys and os for imports.
>>
>>
>>> As it is, you're apparently looping, comparing the byte memory size
>>> of a
>>> string (which is typically 4 bytes per character) with the number of
>>> significant bits in an unrelated number.
>>>
>>> I suspect what you want is something resembling (untested):
>>>
>>>      mybytes = bytes( "%x" % data, "ascii")
>>>      newdata = binascii.unexlify(mybytes)
>>>
>>> I was comparing them but I think I understand how to compare them well,
>> now I want to convert them both to binary so that I can XOR them
>> together.
>> Thank you for your time and help Dave, now I need to reply to Ramit.
>>
>>>
>>> -- 
>>> DaveA
>>>
>>
>>
>>
>> _______________________________________________
>> Tutor maillist  -  Tutor at python.org
>> To unsubscribe or change subscription options:
>> http://mail.python.org/mailman/listinfo/tutor
>>
>
>


More information about the Tutor mailing list