def getComponentByPosition(self, idx, default=noValue, instantiate=True):
try:<EOL><INDENT>componentValue = self._componentValues[idx]<EOL><DEDENT>except IndexError:<EOL><INDENT>componentValue = noValue<EOL><DEDENT>if not instantiate:<EOL><INDENT>if componentValue is noValue or not componentValue.isValue:<EOL><INDENT>return default<EOL><DEDENT>else:<EOL><INDENT>return componentValue<EOL><DEDENT><DEDENT>if componentValue is noValue:<EOL><INDENT>self.setComponentByPosition(idx)<EOL><DEDENT>componentValue = self._componentValues[idx]<EOL>if default is noValue or componentValue.isValue:<EOL><INDENT>return componentValue<EOL><DEDENT>else:<EOL><INDENT>return default<EOL><DEDENT>
Returns |ASN.1| type component by index.

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

        Parameters
        ----------
        idx: :class:`int`
            Component index (zero-based). Must either refer to an existing
            component or (if *componentType* is set) new ASN.1 schema object gets
            instantiated.

        Keyword Args
        ------------
        default: :class:`object`
            If set and requested component is a schema object, return the `default`
            object instead of the requested component.

        instantiate: :class:`bool`
            If `True` (default), inner component will be automatically instantiated.
            If 'False' either existing component or the `noValue` object will be
            returned.

        Returns
        -------
        : :py:class:`~pyasn1.type.base.PyAsn1Item`
            a PyASN1 object

        Examples
        --------

        .. code-block:: python

            # can also be Set
            class MySequence(Sequence):
                componentType = NamedTypes(
                    NamedType('id', OctetString())
                )

            s = MySequence()

            # returns component #0 with `.isValue` property False
            s.getComponentByPosition(0)

            # returns None
            s.getComponentByPosition(0, default=None)

            s.clear()

            # returns noValue
            s.getComponentByPosition(0, instantiate=False)

            # sets component #0 to OctetString() ASN.1 schema
            # object and returns it
            s.getComponentByPosition(0, instantiate=True)

            # sets component #0 to ASN.1 value object
            s.setComponentByPosition(0, 'ABCD')

            # returns OctetString('ABCD') value object
            s.getComponentByPosition(0, instantiate=False)

            s.clear()

            # returns noValue
            s.getComponentByPosition(0, instantiate=False)