It looks like this comment contains a code block delimited with triple backticks. Unfortunately reddit does not have universal support for this syntax and your comment will not render correctly on old reddit and most mobile apps.
For the benefit of people on old reddit, this link will take you to a correct rendering of the comment.
/u/shiningmatcha, it would be appreciated, but not required, if you could edit your comment to use the more compatible four space indention format. For single lines or inline code you can use single backticks.
It’s to pack data in a binary format, like you would do in C with a structure. The doc is rather well explained. Here I could have wrote it as text to add a few GB of disk usage, but I chose to just make it more obscure :)
I found the doc too brief. That’s why I asked. I only know Python. The doc says the method “Return a bytes object containing the values v1, v2, ...”. How is a bytes object different from a string?
A bytes object in python is just a string of bytes, not encoded like a str is. So struct helps to pack values as raw bytes — for example, on my code above (please don’t learn from it ^^"), it packs integer values into 4 bytes each
View all comments
Show parent comment
1
u/shiningmatcha Feb 21 '21
What does
struct.packdo?