INNER CODE UNIT · Python

from_rows

webartifex/intro-to-python · 11_classes/sample_package/matrix.py:81

    def from_rows(cls, data):
        """See docstring for .__init__()."""
        # Some users may want to use this .from_rows() constructor
        # to explicitly communicate that the data are in row-major order.
        # Otherwise, this method is redundant.
        return cls(data)

    def __repr__(self):
        """Text representation of a Matrix."""
        name = self.__class__.__name__
        args = ", ".join(
            "(" + ", ".join(repr(c) for c in r) + ",)" for r in self._entries
        )
        return f"{name}(({args}))"

    def __str__(self):
        """Human-readable text representation of a Matrix."""
        name = self.__class__.__name__

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…