Skip to main content

Data structure for complexe enumeration.

Project description

Catalog is a data structure for storing complex enumeration. It provides a clean definition pattern and several options for member lookup.

Supports Python 2.7, 3.3+


pip install pycatalog


from catalog import Catalog

class Color(Catalog):
    _attrs = 'value', 'label', 'other'
    red = 1, 'Red', 'stuff'
    blue = 2, 'Blue', 'things'

# Access values as Attributes

# Call to look up members by attribute value
> Color('Blue', 'label')

# Calling without attribute specified assumes first attribute defined in `_attrs`
> Color(1)


_attrs: Defines names of attributes of members. (default: ['value'])

_member_class: Override the class used to create members. Create a custom member class by extending CatalogMember.


_zip: Return all members as a tuple. If attrs are provided as positional arguments, only those attributes will be included, and in that order. Otherwise all attributes are included followed by the member name.

> Color._zip()
(('red', 1, 'Red', 'stuff'), ('blue', 2, 'Blue', 'things'))
> Colot._zip('value', 'label')
((1, 'Red'), (2, 'Blue'))


1.2.0 - Add support for Python 2. (Wrong direction. I know)

1.1.1 - Add _zip method

1.0.0 - Initial build and packaging

Project details

Download files

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

Files for pycatalog, version 1.2.0
Filename, size File type Python version Upload date Hashes
Filename, size pycatalog-1.2.0-py3.5.egg (6.8 kB) File type Egg Python version 3.5 Upload date Hashes View
Filename, size pycatalog-1.2.0.tar.gz (4.6 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page