bronx.stdtypes.catalog

A simple class for managing a collection of items.

Classes

class bronx.stdtypes.catalog.Catalog(items=(), weak=False, **kw)[source]

Bases: object

A simple class for managing a collection of items.

The interface is very light : add(), discard() and clear() are the more heavily used

Of 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

add(*items)[source]

Add the item entry in the current catalog.

clear()[source]

Completely clear the list of items previously recorded in this catalog.

discard(bye)[source]

Remove the bye entry from current catalog.

property filled

Boolean value, true if there is at least one item in the catalog.

classmethod fullname()[source]

Returns a nicely formatted name of the current class (dump usage).

items()[source]

Catalog items.

In python2, a list that contains a copy of the catalog items. In python3; an iterator over catalog items.

pop()[source]

Remove and return an arbitrary element from the catalog

property weak

Boolean value, true if the catalog is built with weak references.