1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Is this readunsignedvarint python code correct?

Discussion in 'Off-Topic' started by MFD, May 4, 2020.

  1. MFD

    MFD Silverfish

    Messages:
    23
    @staticmethod
    def readUnsignedVarint(stream):
    value = 0;
    i = 0
    while(true):
    if(i > 63):
    raise ValueError('Varint did not terminate after 10 bytes!')
    b = stream.encode()
    value |= (b << i)
    i += 7
    if(b & 0x80):
    break
    return value
     
  2. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    Would you mind putting the code in a codeblock? Whitespace is significant in python. Also, can't you just try to run it?
     
  3. MFD

    MFD Silverfish

    Messages:
    23
    Ik I’ll tell you on discord
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.