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

Jordan wolfrage8765 at gmail.com
Thu Jul 19 20:48:06 CEST 2012



On 07/19/2012 12:46 PM, Dave Angel wrote:
> On 07/19/2012 01:41 AM, wolfrage8765 at gmail.com wrote:
>> On Thu, Jul 19, 2012 at 12:16 AM, Dave Angel <d at davea.name> wrote:
<SNIP>
> That was just the first line that was not indented.  If I thought you
> had a one-line while loop, I certainly would have just indented it.  But
> I'm sure you have some unknown number of additional lines that were
> indented in your original.  Please post in text form.
I see now, I am sorry I did not know that Thunderbird had eliminated all
of my indentation. I had set it to plain text, but I guess it is not to
be trusted. I simply looked at the reply email and saw the line that you
pointed out and at that time figured Thunderbird had just word wrapped
that line on me. Would it be acceptable to add an attached Python file?
<SNIP>
> Lots of details that have nothing to do with it.  For example, that
> whole thing about adding random digits together.  You could replace the
> whole thing with a simple assignment of a value that doesn't work for you.
OK I will, that was a test script and I was testing multiple things, I
did try to get rid of most of the cruft but I will attempt to do better
in the future. <SNIP>
>> 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.
> Ah, so you don't actually want binary at all!!!   Why not state the real
> problem up front?  You can XOR two integers, without bothering to
> convert to a string of ones and zeroes.  Use the carat operator.
>
> print( 40 ^ 12)
>
> I suspect there's an equivalent for strings or byte-strings.  But if
> not, it's a simple loop.
Actually I do want binary, as it serves as an advantage for the overall
program that I am building.
>
>


More information about the Tutor mailing list