def pt(n):
    """
    Return list of pythagorean triples as non-descending tuples
    of ints from 1 to n.

    Assume n is positive.

    @param int n: upper bound of pythagorean triples
    """
    # helper to check whether a triple is pythagorean and non_descending
    # you could also use a lambda instead of this nested function def.
    def _ascending_pythagorean(t):
        # """
        # Return whether t is pythagorean and non-descending.
        #
        # @param tuple[int] t: triple of integers to check
        # """
        return (t[0] <= t[1] <= t[2]) and (t[0]**2 + t[1]**2) == t[2]**2

    # filter just the ones that satisfy ascending_pythagorean
    # produce a list from the filter for ascending_pythagoreans from...
    return list(filter(_ascending_pythagorean,
                       # ...list of all triples in the range 1..n
                       [(i, j, k)
                        for i in range(1, n + 1)
                        for j in range(1, n + 1)
                        for k in range(1, n + 1)]))