def setComponentByPosition(self, idx, value=noValue,<EOL>verifyConstraints=True,<EOL>matchTags=True,<EOL>matchConstraints=True):
componentType = self.componentType<EOL>componentTypeLen = self._componentTypeLen<EOL>try:<EOL><INDENT>currentValue = self._componentValues[idx]<EOL><DEDENT>except IndexError:<EOL><INDENT>currentValue = noValue<EOL>if componentTypeLen:<EOL><INDENT>if componentTypeLen < idx:<EOL><INDENT>raise error.PyAsn1Error('<STR_LIT>')<EOL><DEDENT>self._componentValues = [noValue] * componentTypeLen<EOL><DEDENT><DEDENT>if value is noValue:<EOL><INDENT>if componentTypeLen:<EOL><INDENT>value = componentType.getTypeByPosition(idx)<EOL>if isinstance(value, base.AbstractConstructedAsn1Item):<EOL><INDENT>value = value.clone(cloneValueFlag=componentType[idx].isDefaulted)<EOL><DEDENT><DEDENT>elif currentValue is noValue:<EOL><INDENT>raise error.PyAsn1Error('<STR_LIT>')<EOL><DEDENT><DEDENT>elif not isinstance(value, base.Asn1Item):<EOL><INDENT>if componentTypeLen:<EOL><INDENT>subComponentType = componentType.getTypeByPosition(idx)<EOL>if isinstance(subComponentType, base.AbstractSimpleAsn1Item):<EOL><INDENT>value = subComponentType.clone(value=value)<EOL><DEDENT>else:<EOL><INDENT>raise error.PyAsn1Error('<STR_LIT>' % componentType.__class__.__name__)<EOL><DEDENT><DEDENT>elif currentValue is not noValue and isinstance(currentValue, base.AbstractSimpleAsn1Item):<EOL><INDENT>value = currentValue.clone(value=value)<EOL><DEDENT>else:<EOL><INDENT>raise error.PyAsn1Error('<STR_LIT>' % componentType.__class__.__name__)<EOL><DEDENT><DEDENT>elif (matchTags or matchConstraints) and componentTypeLen:<EOL><INDENT>subComponentType = componentType.getTypeByPosition(idx)<EOL>if subComponentType is not noValue:<EOL><INDENT>subtypeChecker = (self.strictConstraints and<EOL>subComponentType.isSameTypeWith or<EOL>subComponentType.isSuperTypeOf)<EOL>if not subtypeChecker(value, matchTags, matchConstraints):<EOL><INDENT>if not componentType[idx].openType:<EOL><INDENT>raise error.PyAsn1Error('<STR_LIT>' % (value, componentType))<EOL><DEDENT><DEDENT><DEDENT><DEDENT>if verifyConstraints and value.isValue:<EOL><INDENT>try:<EOL><INDENT>self.subtypeSpec(value, idx)<EOL><DEDENT>except error.PyAsn1Error:<EOL><INDENT>exType, exValue, exTb = sys.exc_info()<EOL>raise exType('<STR_LIT>' % (exValue, self.__class__.__name__))<EOL><DEDENT><DEDENT>if componentTypeLen or idx in self._dynamicNames:<EOL><INDENT>self._componentValues[idx] = value<EOL><DEDENT>elif len(self._componentValues) == idx:<EOL><INDENT>self._componentValues.append(value)<EOL>self._dynamicNames.addField(idx)<EOL><DEDENT>else:<EOL><INDENT>raise error.PyAsn1Error('<STR_LIT>')<EOL><DEDENT>return self<EOL>
Assign |ASN.1| type component by position.

        Equivalent to Python sequence item assignment operation (e.g. `[]`).

        Parameters
        ----------
        idx : :class:`int`
            Component index (zero-based). Must either refer to existing
            component (if *componentType* is set) or to N+1 component
            otherwise. In the latter case a new component of given ASN.1
            type gets instantiated and appended to |ASN.1| sequence.

        Keyword Args
        ------------
        value: :class:`object` or :py:class:`~pyasn1.type.base.PyAsn1Item` derivative
            A Python value to initialize |ASN.1| component with (if *componentType* is set)
            or ASN.1 value object to assign to |ASN.1| component.

        verifyConstraints : :class:`bool`
             If `False`, skip constraints validation

        matchTags: :class:`bool`
             If `False`, skip component tags matching

        matchConstraints: :class:`bool`
             If `False`, skip component constraints matching

        Returns
        -------
        self