ATLAS Offline Software
Public Member Functions | List of all members
python.Utilities.ldict Class Reference
Inheritance diagram for python.Utilities.ldict:
Collaboration diagram for python.Utilities.ldict:

Public Member Functions

def __init__ (self, **args)
 
def __setitem__ (self, k, v)
 
def update (self, **args)
 
def clone (self, **args)
 

Detailed Description

A dictionnary which items can not be modified once set.

Also implements 2 additional features :
 - a clone method to conveniently create a new version with only some items changed
 - all items are also attributes (i.e. d['a'] can be accessed by d.a : this is mostly for easier interactive inspection)

Definition at line 139 of file Utilities.py.

Constructor & Destructor Documentation

◆ __init__()

def python.Utilities.ldict.__init__ (   self,
**  args 
)

Definition at line 146 of file Utilities.py.

146  def __init__(self, **args):
147  super().__init__(**args)
148  # make key aivailable as attribute
149  for k,v in args.items():
150  super().__setattr__(k,v)
151 

Member Function Documentation

◆ __setitem__()

def python.Utilities.ldict.__setitem__ (   self,
  k,
  v 
)

Definition at line 152 of file Utilities.py.

152  def __setitem__(self, k, v):
153  if k in self:
154  if v!=self[k]:
155  raise KeyError(f"Can't override self[{k}] == {self[k]} with new value {v}")
156  else:
157  super().__setitem__(k,v)
158  super().__setattr__(k,v)
159 

◆ clone()

def python.Utilities.ldict.clone (   self,
**  args 
)

Definition at line 164 of file Utilities.py.

164  def clone(self,**args):
165  from copy import deepcopy
166  o = deepcopy(self)
167  for k,v in args.items():
168  # bypass the protection to update the user given items
169  dict.__setitem__(o,k,v)
170  dict.__setattr__(o,k,v)
171  return o
172 

◆ update()

def python.Utilities.ldict.update (   self,
**  args 
)

Definition at line 160 of file Utilities.py.

160  def update(self, **args): # we need to redefine it
161  for k,v in args.items():
162  self[k]=v
163 

The documentation for this class was generated from the following file:
python.Utilities.clone
clone
Definition: Utilities.py:134
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
python.Utilities.__setattr__
__setattr__
Definition: Utilities.py:110
dqt_zlumi_pandas.update
update
Definition: dqt_zlumi_pandas.py:42
python.Bindings.__setitem__
__setitem__
Definition: Control/AthenaPython/python/Bindings.py:763