def set_symbol(self, name, value=None, group=None):
        "set a symbol in the table"
        grp = self._sys.localGroup
        if group is not None:
            grp = self.get_group(group)
        names = []

        for n in name.split('.'):
            if not isValidName(n):
                raise SyntaxError("invalid symbol name '%s'" % n)
            names.append(n)

        child = names.pop()
        for nam in names:
            if hasattr(grp, nam):
                grp = getattr(grp, nam)
                if not isgroup(grp):
                    raise ValueError(
                "cannot create subgroup of non-group '%s'" % grp)
            else:
                setattr(grp, nam, Group())

        setattr(grp, child, value)
        if (grp, child) in self.__callbacks:
            for func, args, kws in self.__callbacks[(grp, child)]:
                kws.update({'group': grp, 'value': value,
                            'symbolname': child})
                func(*args, **kws)
        return getattr(grp, child)
dataset/ETHPy150Open xraypy/xraylarch/lib/symboltable.py/SymbolTable.set_symbol/original