# `defaultdict_fromkey`

digraph inheritance49c835ca04 { bgcolor=transparent; rankdir=UD; ratio=compress; size="8.0, 12.0"; "defaultdict" [URL="taurus.core.util.containers-defaultdict.html#taurus.core.util.containers.defaultdict",color=dodgerblue1,fillcolor=white,fontcolor=black,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.5,shape=box,style=rounded,target="_top",tooltip="defaultdict(default_factory=None, /, [...]) --> dict with default factory"]; "defaultdict_fromkey" [URL="#taurus.core.util.containers.defaultdict_fromkey",color=dodgerblue1,fillcolor=white,fontcolor=black,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.5,shape=box,style=rounded,target="_top",tooltip="Creates a dictionary with a default_factory function that creates new"]; "defaultdict" -> "defaultdict_fromkey" [arrowsize=0.5,style="setlinewidth(0.5)"]; }

class defaultdict_fromkey

  Creates a dictionary with a default_factory function that creates new elements using key as argument.

  Usagenew_dict = defaultdict_fromkey(method)

    where method like (lambda key: return new_obj(key))

  Each time that new_dict[key] is called with a key that doesn’t exist, method(key) is used to create the value Copied from PyAlarm device server

  Import from `taurus.core.util.containers` as:

      from taurus.core.util.containers import defaultdict_fromkey