What is the equivalent of BinaryWriter.Write() from C# in Python?

424 views Asked by At

So I have this function in a C# program:

public void Write(BinaryWriter writer)
    {
        writer.Write(0x6369676F6C6572uL | ((ulong)Type << 56));
        writer.Write(Revision);
        writer.Write((ulong)(int)((uint)IsFavorite.ToInt() & 1u));
    }

I would like to translate it to Python but I'm not sure how, I found a package for python called binstream but I'm not sure how am I supposed to translate stuff like 0x6369676F6C6572uL to Python.

Any advice is welcome!

1

There are 1 answers

0
user3599976 On

I had this same problem and found this https://pypi.org/project/binstream/ it claims to be compatible with BinaryReader and BinaryWriter