Java Integer.ParseInt translation to python

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jose isaias cabrera

    #1

    Java Integer.ParseInt translation to python


    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.p arseInt(string, 16);

    Has anyone ported any java programs to python and has translated this?

    any help would be greatly appreciated.

    thanks.

    josé

  • Paul Rubin

    #2
    Re: Java Integer.ParseIn t translation to python

    "jose isaias cabrera" <jicman@cinops. xerox.com> writes:[color=blue]
    > 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.p arseInt(string, 16);
    >
    > Has anyone ported any java programs to python and has translated this?[/color]

    I think the Python equivalent would be:

    buffer[0] = chr(int(string, 16))

    That is, you're trying to convert two hex digits into a single char, right?

    Comment

    • ech0

      #3
      Re: Java Integer.ParseIn t translation to python

      buffer[0] = int(string,16) & 0xff

      that should work

      Comment

      • jose isaias cabrera

        #4
        Re: Java Integer.ParseIn t translation to python


        thanks everyone...!

        ----- Original Message -----
        From: "ech0" <the.ech0@gmail .com>
        Newsgroups: comp.lang.pytho n
        To: <python-list@python.org >
        Sent: Monday, January 31, 2005 7:27 PM
        Subject: Re: Java Integer.ParseIn t translation to python

        [color=blue]
        > buffer[0] = int(string,16) & 0xff
        >
        > that should work
        >
        > --
        > http://mail.python.org/mailman/listinfo/python-list
        >[/color]

        Comment

        Working...