Append code for creating variable with bool if it's instance of list
        with a name ``{variable}_is_dict``. Similar to `create_variable_with_length`.
19740
def create_variable_is_dict(self):
        
        variable_name = '{}_is_dict'.format(self._variable)
        if variable_name in self._variables:
            return
        self._variables.add(variable_name)
        self.l('{variable}_is_dict = isinstance({variable}, dict)')
1312004
def append_code_expr(self, code):
        """"""
        # expects a string.
        if isinstance(code, str) and not isinstance(code, unicode):
            code = unicode(code)
        if not isinstance(code, unicode):
            raise TypeError("string expected")
        log.debug("compiling code %s...", code)
        try:
            code_obj = compile(code, '<string>', 'eval')
            self.code_objs[code] = code_obj
        except SyntaxError as syntax_err:
            log.error("cannot compile %s: %s", code, syntax_err)
            raise
        log.debug("compiled code %s", code)
1301935
def create_variable(self, varname, vtype=None):
        

        var_types = ('string', 'int', 'boolean', 'double')
        vname = varname
        var = None
        type_from_name = 'string'  # default type
        if ':' in varname:
            type_from_name, vname = varname.split(':')
            #  Fix incorrect order bug #33
            if type_from_name not in (var_types):
                #  Swap order
                type_from_name, vname = vname, type_from_name
                if type_from_name not in (var_types):
                    raise Exception('Undefined variable type in "{0}"'.format(varname))

        if vname in self.tkvariables:
            var = self.tkvariables[vname]
        else:
            if vtype is None:
                # get type from name
                if type_from_name == 'int':
                    var = tkinter.IntVar()
                elif type_from_name == 'boolean':
                    var = tkinter.BooleanVar()
                elif type_from_name == 'double':
                    var = tkinter.DoubleVar()
                else:
                    var = tkinter.StringVar()
            else:
                var = vtype()

            self.tkvariables[vname] = var
        return var
1207394
def variablename(var):
    
    s=[tpl[0] for tpl in itertools.ifilter(lambda x: var is x[1], globals().items())]
    s=s[0].upper()
    return s
1263875
def add_variable(self, start, variable):
        

        size = variable.size if variable.size is not None else 1

        self.add_object(start, variable, size)
750667
def add(self, **kwargs):
        
        for name, var in kwargs.items():
            if iskeyword(name):
                var['name'] = name
                name = '_' + name
            if name in self:
                self[name] = merge(self[name], Variable(self.default_type, **var))
            else:
                self[name] = Variable(self.default_type, **var)
        return self
683326
def load_from_dict(self, data: dict, overwrite: bool=True):
        
        if data is None or data == {}:
            return False
        # Loop over items
        if isinstance(data, list) or isinstance(data, tuple):
            # Pick a random item from the tuple.
            if len(data[0]) != 2:
                raise exc.LoaderException("Cannot load data with length {}".format(len(data[0])))
            items = data
        elif isinstance(data, dict) or isinstance(data, self.__class__):
            items = data.items()
        else:
            raise exc.LoaderException("Cannot load data of type {}".format(type(data)))
        for key, item in items:
            assert isinstance(key, str)
            if hasattr(self, key) and not overwrite:
                # Refuse to overwrite existing data.
                continue
            # Check name to verify it's safe.
            if self.safe_load:
                if key.startswith("__") or key in ['dump', 'items', 'keys', 'values',
                                                   'iter_list', 'load_from_dict', 'iter_list_dump',
                                                   'parsed', 'safe_load']:
                    # It's evil!
                    key = "unsafe_" + key
            if '.' in key:
                # Doubly evil!
                key = key.replace('.', '_')
            if isinstance(item, dict):
                # Create a new ConfigKey object with the dict.
                ncfg = ConfigKey()
                # Parse the data.
                ncfg.load_from_dict(item)
                # Set our new ConfigKey as an attribute of ourselves.
                setattr(self, key, ncfg)
            elif isinstance(item, list):
                # Iterate over the list, creating ConfigKey items as appropriate.
                nlst = self.iter_list(item)
                # Set our new list as an attribute of ourselves.
                setattr(self, key, nlst)
            else:
                # Set the item as an attribute of ourselves.
                setattr(self, key, item)
        # Flip the parsed flag,
        self.parsed = True
978175
def append(self, obj):
        
        if isinstance(obj, dict) and self._col_names:
            obj = [obj.get(col, None) for col in self._col_names]
        assert isinstance(obj, list), \
            "obj appended to ReprListList needs to be a list or dict"
        self._original.append(obj)
1285406
def varmap(func, var, context=None, name=None):
    
    if context is None:
        context = {}
    objid = id(var)
    if objid in context:
        return func(name, '<...>')
    context[objid] = 1
    if isinstance(var, (list, tuple)):
        ret = [varmap(func, f, context, name) for f in var]
    else:
        ret = func(name, var)
        if isinstance(ret, dict):
            ret = dict((k, varmap(func, v, context, k))
                       for k, v in iteritems(var))
    del context[objid]
    return ret
494341
def set_target_variable (self, targets, variable, value, append=0):
        
        if isinstance (targets, str):
            targets = [targets]
        if isinstance(value, str):
            value = [value]

        assert is_iterable(targets)
        assert isinstance(variable, basestring)
        assert is_iterable(value)

        if targets:
            if append:
                bjam_interface.call("set-target-variable", targets, variable, value, "true")
            else:
                bjam_interface.call("set-target-variable", targets, variable, value)
117424
def _has_var_attr(cls, dataset, vname, attr, concept_name, priority=BaseCheck.HIGH):
        
        val = True
        msgs = []
        if vname not in dataset.variables:
            val = False
            msgs.append("Variable '{}' not present while checking for attr '{}' for IOOS concept: '{}'".format(vname, attr, concept_name))
        else:
            v = dataset.variables[vname]
            if attr not in v.ncattrs():
                val = False
                msgs.append("Attr '{}' not present on var '{}' while checking for IOOS concept: '{}'".format(attr, vname, concept_name))

        return Result(priority, val, concept_name, msgs)
1038686
def code(self, value):
        
        if value not in list(defines.Codes.LIST.keys()) and value is not None:
            raise AttributeError
        self._code = value
1262622
def append!(errors, attr, key, val)
      return unless val.present?

      errors ||= {}
      errors[attr] ||= {}
      errors[attr][key] = val
    end
214505
def _is_variable_extends(extend_node):
    
    if django.VERSION < (1, 4):
        return extend_node.parent_name_expr  # Django 1.3
    else:
        # The FilterExpression.var can be either a string, or Variable object.
        return not isinstance(extend_node.parent_name.var, six.string_types)
1197895
void addToOutputVar(PyExpr pyExpr) {
    boolean isList = pyExpr instanceof PyListExpr;
    if (isList && !getOutputVarIsInited()) {
      appendLine(getOutputVarName(), " = ", pyExpr.getText());
    } else {
      initOutputVarIfNecessary();
      String function = isList ? ".extend(" : ".append(";
      appendLine(getOutputVarName(), function, pyExpr.getText(), ")");
    }
    setOutputVarInited();
  }
772313
def add_variable(self, name):
        """"""
        if name in self._variables:
            raise ValueError(
                "A variable named " + name + " already exists."
            )
        self._variables[name] = len(self._variables)
        self.bounds[name] = (0, None)

        new_col = np.zeros(shape=[len(self._constraints), 1])
        self._add_col_to_A(new_col)
        self._reset_solution()
501775
def check_is_a_mapping(var, allow_none=False):
    
    if not is_a_mapping(var, allow_none=allow_none):
        raise TypeError("var must be a dict, however type(var) is {}"
                        .format(type(var)))