Skip to main content

This package contains the metatools module, which provides a utility class (MetaClass) which metaclasses can extend. It provides three static methods (available only on classes inheriting from MetaClass; they will not clutter up your actual classes) which can be used to enhance inheritance.

The most important of these static methods is the iter_bases() method. When passed a list of base classes, such as those passed to the __new__() method, it generates a list of the superclasses in proper Python Method Resolution Order. This can be used with the inherit_dict() and inherit_set() static methods.

Both inherit_dict() and inherit_set() have similar interfaces. When passed a base class, the dictionary for the class being constructed, and the name of an attribute containing the dictionary or set which should have inheritance rules applied, they look up the attribute in both the base class and in the namespace dictionary, then walk through all entries in the base class’s version; if the entry does not currently exist in the namespace’s version of that dictionary or set, then it is automatically added. Both routines return a list of items added, if the metaclass needs to perform any additional post-processing on the entries. The items may also be filtered by passing a callable returning True or False as the inherit parameter to the routines. Additionally, if inherit is False or None (or any other value that tests as False), then the items are not automatically added to the dictionary or set, but are still provided in the list of returned items.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Metatools-0.1.tar.gz (16.7 kB view details)

Uploaded Source

File details

Details for the file Metatools-0.1.tar.gz.

File metadata

  • Download URL: Metatools-0.1.tar.gz
  • Upload date:
  • Size: 16.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for Metatools-0.1.tar.gz
Algorithm Hash digest
SHA256 4f73482d744e74aa98eb4a7b3649bc557c360ed7cd4b5f46d5ecf13cf2f4a909
MD5 ed2a1fef8964136d80aba48a2c40910c
BLAKE2b-256 fb5c41aa56ea03a25cbb359c6dcd199e10743d45247f094d406224cb0067b4e0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page