Structs in Python

(written by lawrence krubner, however indented passages are often quotes). You can contact lawrence at: lawrence@krubner.com, or follow me on Twitter.

Interesting:

A record (aka “struct” in C) is a pre-defined collection of values where each is accessed by a unique name. Depending on the nature of the data, records may be a superior alternative to dictionaries and instances of custom classes.

PyRecord allows you to use records in Python v2.7 to v3.x and PyPy v2, and can be thought of as an improved namedtuple.

In Python terms, a record is an instance of any class for which you define some attributes but no methods. Such classes, which are known as record types, can be easily written but require a lot of noisy boilerplate. This is where PyRecord comes into play: It saves you the boilerplate so you can focus on what really matters.

Post external references

  1. 1
    https://pythonhosted.org/pyrecord/
Source