Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a class constructor for namedtuples with default values
namedtuple classes are great as pure data objects one can store things in and then access them really easily. The problem is that if a new field is added to a namedtuple, all places creating instances of it has to be modified to provide a value for that new field. The default_namedtuple class constructor implemented in this commit constructs namedtuples with default values for (some) fields and fields without any value passed defaulting to None. Such default namedtuple classes are still great for storing data and e.g. passing data to functions/methods grouped into a few objects (like DeviceInfo, FormatInfo,...) passed as arguments, but allow us to add extra fields in the future (e.g. a new device attribute to DeviceInfo) without breaking the API.
- Loading branch information
Showing
2 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters