TypedOrderedDict

class datastructuretools.TypedOrderedDict(items=None, item_class=None)

A typed ordered dictionary.

Example 1. Initializes from list of pairs:

>>> dictionary = datastructuretools.TypedOrderedDict([
...     ('color', 'red'),
...     ('directive', Markup(r'\italic Allegretto')),
...     ])
>>> print(format(dictionary))
abjad.datastructuretools.TypedOrderedDict(
    [
        ('color', 'red'),
        (
            'directive',
            markuptools.Markup(
                contents=[
                    markuptools.MarkupCommand(
                        'italic',
                        'Allegretto'
                        ),
                    ],
                ),
            ),
        ]
    )

Example 2. Initializes from built-in dictionary:

>>> dictionary = {
...     'color': 'red',
...     'directive': Markup(r'\italic Allegretto'),
...     }
>>> dictionary = datastructuretools.TypedOrderedDict(
...     dictionary
...     )
>>> print(format(dictionary))
abjad.datastructuretools.TypedOrderedDict(
    [
        ('color', 'red'),
        (
            'directive',
            markuptools.Markup(
                contents=[
                    markuptools.MarkupCommand(
                        'italic',
                        'Allegretto'
                        ),
                    ],
                ),
            ),
        ]
    )

Example 3. Initializes from other typed ordered dictionary:

>>> dictionary_1 = datastructuretools.TypedOrderedDict([
...     ('color', 'red'),
...     ('directive', Markup(r'\italic Allegretto')),
...     ])
>>> dictionary_2 = datastructuretools.TypedOrderedDict(
...     dictionary_1
...     )
>>> print(format(dictionary_2))
abjad.datastructuretools.TypedOrderedDict(
    [
        ('color', 'red'),
        (
            'directive',
            markuptools.Markup(
                contents=[
                    markuptools.MarkupCommand(
                        'italic',
                        'Allegretto'
                        ),
                    ],
                ),
            ),
        ]
    )

Lineage

digraph InheritanceGraph { graph [background=transparent, bgcolor=transparent, color=lightslategrey, fontname=Arial, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, root="__builtin__.object", splines=spline, style="dotted, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=12, penwidth=2, style="filled, rounded"]; edge [color=lightsteelblue2, penwidth=2]; subgraph cluster_abctools { graph [label=abctools]; "abjad.tools.abctools.AbjadObject.AbjadObject" [color=1, group=0, label=AbjadObject, shape=box]; "abjad.tools.abctools.AbjadObject.AbstractBase" [color=1, group=0, label=AbstractBase, shape=box]; "abjad.tools.abctools.AbjadObject.AbstractBase" -> "abjad.tools.abctools.AbjadObject.AbjadObject"; } subgraph cluster_datastructuretools { graph [label=datastructuretools]; "abjad.tools.datastructuretools.TypedCollection.TypedCollection" [color=3, group=2, label=TypedCollection, shape=oval, style=bold]; "abjad.tools.datastructuretools.TypedOrderedDict.TypedOrderedDict" [color=black, fontcolor=white, group=2, label=<<B>TypedOrderedDict</B>>, shape=box, style="filled, rounded"]; "abjad.tools.datastructuretools.TypedCollection.TypedCollection" -> "abjad.tools.datastructuretools.TypedOrderedDict.TypedOrderedDict"; } subgraph cluster_rhythmmakertools { graph [label=rhythmmakertools]; "abjad.tools.rhythmmakertools.PartitionTable.PartitionTable" [color=4, group=3, label=PartitionTable, shape=box]; } subgraph cluster_builtins { graph [label=builtins]; "builtins.object" [color=2, group=1, label=object, shape=box]; } "abjad.tools.abctools.AbjadObject.AbjadObject" -> "abjad.tools.datastructuretools.TypedCollection.TypedCollection"; "abjad.tools.datastructuretools.TypedOrderedDict.TypedOrderedDict" -> "abjad.tools.rhythmmakertools.PartitionTable.PartitionTable"; "builtins.object" -> "abjad.tools.abctools.AbjadObject.AbstractBase"; }

Bases

Attribute summary

clear() Clears typed ordered dictionary.
copy() Copies typed ordered dictionary.
get(i[, default]) Aliases OrderedDict.get().
has_key(key) Aliases OrderdDict.has_key().
item_class Gets item class of collection.
items() Aliases OrderedDict.items().
keys() Aliases OrderedDict.keys().
pop(key[, default]) Aliases OrderedDict.pop().
popitem() Aliases OrderedDict.popitem().
setdefault(key[, default]) Aliases OrderedDict.setdefault().
update(*arguments, **keywords) Aliases OrderedDict.update().
values() Aliases OrderedDict.values().
__cmp__(argument) Aliases OrderedDict.__cmp__().
__contains__(key) Aliases OrderedDict.__contains__().
__delitem__(i) Aliases OrderedDict.__delitem__().
__eq__(argument) Is true when argument is a typed collection with items that compare equal to those of this typed collection.
__format__([format_specification]) Formats Abjad object.
__ge__(argument) Is true when typed ordered dictionary is greater than or equal to argument.
__getitem__(argument) Gets item or slice identified by argument.
__gt__(argument) Is true when typed ordered dictionary is greater than argument.
__hash__() Hashes typed collection.
__iter__() Iterates typed collection.
__le__(argument) Is true when typed ordered dictionary is less than or equal to argument.
__len__() Gets length of typed collection.
__lt__(argument) Is true when typed ordered dictionary is less than argument.
__ne__(argument) Is true when typed ordered dictionary is not equal to argument.
__repr__() Gets interpreter representation of Abjad object.
__reversed__() Aliases OrderedDict.__reversed__().
__setitem__(i, argument) Changes items in argument to items and sets.

Read-only properties

(TypedCollection).item_class

Gets item class of collection.

Collection coerces items according to item_class.

Returns class.

Methods

TypedOrderedDict.clear()

Clears typed ordered dictionary.

Returns none.

TypedOrderedDict.copy()

Copies typed ordered dictionary.

Returns new typed ordered dictionary.

TypedOrderedDict.get(i, default=None)

Aliases OrderedDict.get().

Returns item or raises key error.

TypedOrderedDict.has_key(key)

Aliases OrderdDict.has_key().

Returns true or false.

TypedOrderedDict.items()

Aliases OrderedDict.items().

Returns generator.

TypedOrderedDict.keys()

Aliases OrderedDict.keys().

Returns generator.

TypedOrderedDict.pop(key, default=None)

Aliases OrderedDict.pop().

Returns items.

TypedOrderedDict.popitem()

Aliases OrderedDict.popitem().

Returns generator.

TypedOrderedDict.setdefault(key, default=None)

Aliases OrderedDict.setdefault().

Returns items.

TypedOrderedDict.update(*arguments, **keywords)

Aliases OrderedDict.update().

Returns none.

TypedOrderedDict.values()

Aliases OrderedDict.values().

Returns generator.

Special methods

TypedOrderedDict.__cmp__(argument)

Aliases OrderedDict.__cmp__().

Returns true or false.

TypedOrderedDict.__contains__(key)

Aliases OrderedDict.__contains__().

Returns true or false.

TypedOrderedDict.__delitem__(i)

Aliases OrderedDict.__delitem__().

Returns none.

(TypedCollection).__eq__(argument)

Is true when argument is a typed collection with items that compare equal to those of this typed collection. Otherwise false.

Returns true or false.

(AbjadObject).__format__(format_specification='')

Formats Abjad object.

Set format_specification to ‘’ or ‘storage’. Interprets ‘’ equal to ‘storage’.

Returns string.

TypedOrderedDict.__ge__(argument)

Is true when typed ordered dictionary is greater than or equal to argument. Otherwise false.

Returns true or false.

TypedOrderedDict.__getitem__(argument)

Gets item or slice identified by argument.

Returns item or slice.

TypedOrderedDict.__gt__(argument)

Is true when typed ordered dictionary is greater than argument. Otherwise false.

Returns true or false.

(TypedCollection).__hash__()

Hashes typed collection.

Required to be explicitly redefined on Python 3 if __eq__ changes.

Returns integer.

(TypedCollection).__iter__()

Iterates typed collection.

Returns generator.

TypedOrderedDict.__le__(argument)

Is true when typed ordered dictionary is less than or equal to argument. Otherwise false.

Returns true or false.

(TypedCollection).__len__()

Gets length of typed collection.

Returns nonnegative integer.

TypedOrderedDict.__lt__(argument)

Is true when typed ordered dictionary is less than argument. Otherwise false.

Returns true or false.

TypedOrderedDict.__ne__(argument)

Is true when typed ordered dictionary is not equal to argument. Otherwise false.

Returns true or false.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.

TypedOrderedDict.__reversed__()

Aliases OrderedDict.__reversed__().

Returns generatos.

TypedOrderedDict.__setitem__(i, argument)

Changes items in argument to items and sets.

Returns none.