bronx.stdtypes.catalog¶
A simple class for managing a collection of items.
Classes¶
- class bronx.stdtypes.catalog.Catalog(items=(), weak=False, **kw)[source]¶
Bases:
objectA simple class for managing a collection of items.
The interface is very light :
add(),discard()andclear()are the more heavily usedOf course a catalog is an iterable object. It is also callable, and then returns a copy of the list of its items. It can be deep-copied or pickled.
- Note:
It looks like the Python’s set builtin type but does not behave the same way. A set builtin, provides a rich set of comparison and logical operators whereas this class has none of them. On the contrary, the set builtin is not hashable (since set is mutable, it would result in inconsistencies between __hash__ and __eq__ which is prohibited) whereas the present class is hashable (it just identifies the object).
- Parameters:
items – Any kind of iterable object that will be used to populate the catalog
weak – If
True, weak references to catalog’s items are kept.kw – Any other named parameters will be added to the catalog’s attributes
- property filled¶
Boolean value, true if there is at least one item in the catalog.
- items()[source]¶
Catalog items.
In python2, a list that contains a copy of the catalog items. In python3; an iterator over catalog items.
- property weak¶
Boolean value, true if the catalog is built with weak references.