AlphaDict

Provides AlphaDict, a frozen OrderedDict where the keys are stored alphabetically.

Classes:

AlphaDict([seq])

Initialize an immutable, alphabetised dictionary.

Functions:

alphabetical_dict(**kwargs)

Returns an OrderedDict with the keys sorted alphabetically.

class AlphaDict(seq=None, **kwargs)[source]

Bases: FrozenOrderedDict[~KT, ~VT]

Initialize an immutable, alphabetised dictionary.

The signature is the same as regular dictionaries.

  • AlphaDict() -> new empty AlphaDict

  • AlphaDict(mapping) -> new AlphaDict initialized from a mapping object’s (key, value) pairs

  • AlphaDict(iterable) -> new AlphaDict initialized as if via:

    d = {}
    for k, v in iterable:
        d[k] = v
    
  • AlphaDict(**kwargs) -> new AlphaDict initialized with the name=value pairs in the keyword argument list.

    For example:

    AlphaDict(one=1, two=2)
    
alphabetical_dict(**kwargs)[source]

Returns an OrderedDict with the keys sorted alphabetically.

Parameters

kwargs

Return type

OrderedDict[str, ~T]