Re: Java Integer.ParseInt translation to python

2005-02-09 Thread comp.lang.java
Ok. Just to end this, here is what is happening with this. Take for example this piece of java code: int i = 235; byte b = (byte)i; this will assign b a value of -21. Huh? Ok, so in java a byte is an 8 bit value between -128 to 127. So, what (byte) does to an integer is to check if the valu

Re: Java Integer.ParseInt translation to python

2005-02-09 Thread Richard Brodie
"John Machin" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > jose isaias cabrera wrote: > > > the question is, how can I make this java (byte) call in python? so > that the > > result would be the right one, "[EMAIL PROTECTED]" > However some Java code (I can't believe that it was

Re: Java Integer.ParseInt translation to python

2005-02-09 Thread jicman
John Machin wrote: > jose isaias cabrera wrote: > However some Java code (I can't believe that it was the Java code that > you posted) has printed NINE bytes which bear no relation that I can > see to any of the TWENTY bytes that the posted Java code should have > stowed in retBuf. I know what yo

Re: Java Integer.ParseInt translation to python

2005-02-09 Thread jicman
Nick Craig-Wood wrote: > When I try your code I get this... ... [clip] ... > Traceback (most recent call last): > File "", line 1, in ? > File "", line 4, in PrepareHash > TypeError: 'str' object is not callable > >>> > > You cant do byte(int(byte,16)) - byte is a string! So you haven't > post

Re: Java Integer.ParseInt translation to python

2005-02-09 Thread John Machin
jose isaias cabrera wrote: > > the question is, how can I make this java (byte) call in python? so that the > result would be the right one, "[EMAIL PROTECTED]" > Let's get this straight: you have 40 hex digits; both your Java code and your Python code each do 20 iterations, printing the 20 bytes

Re: Java Integer.ParseInt translation to python

2005-02-09 Thread Nick Craig-Wood
jose isaias cabrera <[EMAIL PROTECTED]> wrote: [java output] > StringLength = 40 > c1 193 -63 > 7c 124 124 > e1 225 -31 > 86 134 -122 > ab 171 -85 > 94 148 -108 > ee 238 -18 > b0 176 -80 > de 222 -34 > 8a 138 -118 > e3 227 -29 > b5 181 -75 > b7 183 -73 > 51 81 81 > a7 167 -89 > c4

Re: Java Integer.ParseInt translation to python

2005-02-08 Thread jose isaias cabrera
Ok, so this, buffer[0] = (byte)Integer.parseInt(string,16); in java is, partly, this buffer[0] = int(string, 16) in python. But here is my problem. When I call this java subroutine, byte[] decodeKey(String inString) { if (inString == null) return null; System.out.println("Strin

Re: Java Integer.ParseInt translation to python

2005-01-31 Thread jose isaias cabrera
thanks everyone...! - Original Message - From: "ech0" <[EMAIL PROTECTED]> Newsgroups: comp.lang.python To: Sent: Monday, January 31, 2005 7:27 PM Subject: Re: Java Integer.ParseInt translation to python buffer[0] = int(string,16) & 0xff that should work -- ht

Re: Java Integer.ParseInt translation to python

2005-01-31 Thread jose isaias cabrera
Yes, that's my problem. I don't want to go through the java stuff. :-) Thanks. - Original Message - From: "Bill Mill" <[EMAIL PROTECTED]> To: "jose isaias cabrera" <[EMAIL PROTECTED]> Cc: Sent: Monday, January 31, 2005 7:28 PM Subject: Re: J

Re: Java Integer.ParseInt translation to python

2005-01-31 Thread ech0
buffer[0] = int(string,16) & 0xff that should work -- http://mail.python.org/mailman/listinfo/python-list

Re: Java Integer.ParseInt translation to python

2005-01-31 Thread Bill Mill
Jose, On Mon, 31 Jan 2005 19:23:35 -0500, jose isaias cabrera <[EMAIL PROTECTED]> wrote: > > Greetings! > > I've looked through the internet (not long, though) but I have not been able > to find a python translation to > > buffer[0] = (byte)Integer.parseInt(string,16); Tell me what this does,

Re: Java Integer.ParseInt translation to python

2005-01-31 Thread Sean Blakey
On Mon, 31 Jan 2005 19:23:35 -0500, jose isaias cabrera <[EMAIL PROTECTED]> wrote: > > Greetings! > > I've looked through the internet (not long, though) but I have not been able > to find a python translation to > > buffer[0] = (byte)Integer.parseInt(string,16); > > Has anyone ported any java

Re: Java Integer.ParseInt translation to python

2005-01-31 Thread Paul Rubin
"jose isaias cabrera" <[EMAIL PROTECTED]> writes: > I've looked through the internet (not long, though) but I have not > been able to find a python translation to > > buffer[0] = (byte)Integer.parseInt(string,16); > > Has anyone ported any java programs to python and has translated this? I think