def __getattr__(self, name):
        """Access a field of the underlying value.

        Returns :py:`self[name]`.

        Raises
        ------
        :exc:`AttributeError`
            If the layout does not define a field called :py:`name`, or if :py:`name` starts with
            an underscore.
        :exc:`Exception`
            If the bit pattern of the field is not valid according to
            :meth:`.ShapeCastable.from_bits`. Usually this will be a :exc:`ValueError`.
        """
        if isinstance(self.__layout, ArrayLayout):
            raise AttributeError(
                f"Constant with an array layout does not have fields")
        try:
            item = self[name]
        except KeyError:
            raise AttributeError(
                f"Constant with layout {self.__layout!r} does not have a field {name!r}; did you mean "
                f"one of: {', '.join(repr(name) for name, field in self.__layout)}?")
        if name.startswith("_"):
            raise AttributeError(
                f"Field {name!r} of constant with layout {self.__layout!r} has a reserved name and "
                f"may only be accessed by indexing")
        return item
Access a field of the underlying value.

        Returns :py:`self[name]`.

        Raises
        ------
        :exc:`AttributeError`
            If the layout does not define a field called :py:`name`, or if :py:`name` starts with
            an underscore.
        :exc:`Exception`
            If the bit pattern of the field is not valid according to
            :meth:`.ShapeCastable.from_bits`. Usually this will be a :exc:`ValueError`.
        
amaranth/lib/data.py