What is the purpose of "struct" and "array" modules

I

Igor Katson

I pretty much understand what they do, but what's the case of using
these modules by example? Is it something like pickle, to store the data
efficiently in files?
 
M

Matimus

I pretty much understand what they do, but what's the case of using
these modules by example? Is it something like pickle, to store the data
efficiently in files?

For one it provides a mechanism for reading and writing arbitrary file
formats. For example, suppose you wanted to parse a PNG image using
python code. It is likely that that format is described in its
specification using C data structures (I've never looked at PNG format
specifically). In python you can't just read out some data and copy it
directly into a data structure. You could use the struct module
though.

It really has nothing to do with serializing python data structures.
It is (mostly) about data formats and objects defined in other
languages.

Matt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top