[Tutor] conversion confusion

Lloyd Kvam pythontutor at venix.com
Tue Sep 30 13:04:25 EDT 2003


 >>> ord('m')
109
 >>> int('6d',16)
109

So int(value2add,16) should give you the right number.

I assume this relates to the serial processing that you've written about in
the past.  Did you create value2add by using a hex funtion on a character?
Would it be feasible to simply use ord on the original character?

Vicki Stanfield wrote:

> I am trying to OR two values. These values are the hex values minus the 0x
> part. If I had an ASCII 'm' for instance, I would OR the value 6D to the
> existing seed value. When I try this, I get an error.
> 
> CRCval=ord(value2add) ^ ord(seed)
> 
> because the value2add is 2 characters rather than one. Is there an
> established function to take a multi-character string and convert it to a
> numeric value that works with OR?
> 
> --vicki
> 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
> 

-- 
Lloyd Kvam
Venix Corp.
1 Court Street, Suite 378
Lebanon, NH 03766-1358

voice:	603-443-6155
fax:	801-459-9582




More information about the Tutor mailing list