Publisher review:Named Tuples script allows you a fast, lightweight attribute-style access to tuples. This script allows you a fast, lightweight attribute-style access to tuples. It contains a function that returns a new subclass of tuple with named fields.
The principal features are:
- Easy to type/read/modify function signature: NamedTuple('Person', 'name age sex height nationality')
- C-speed attribute lookup using property and itemgetter.
- No instance dictionary means that instances take no more space than a regular tuple.
- Nice docstring is helpful with an editor's tooltips.
- Optional keywords in the contructor for readability and to allow variable order of specifying arguments: Person(name='susan', height=60, nationality='english', sex='f', age=30).
- Key/Value style repr for clearer error messages and for usability at the interactive prompt.
- Named tuples are picklable.
- Clean error messages for missing or misnamed arguments.
- A method similar to str.replace() using a field name (used instead of slicing for updating fields -- instead of t[:2] newval t[3:], write t.replace('f',newval)).
Named Tuples 1.9 is a Python script for Programming Methods and Algorithms scripts design by Raymond Hettinger.
It runs on following operating system: Windows / Linux / Mac OS / BSD / Solaris.
allows you a fast, lightweight attribute-style access to tuples.
Operating system:Windows / Linux / Mac OS / BSD / Solaris