Generally, to import a python module programatically when you know the file's path, you could do something like this:
import importlib.util
import sys
According to PEP 572, section Scope of the target, the following examples of assignment expressions should be invalid and raise TargetScopeError
.
[i := i+1 for i in range(5)]
Python 3.8.0a1 (tags/v3.8.0a1:e75eeb00b5, Feb 3 2019, 20:47:39) [MSC v.1916 64 bit (AMD64)] on win32
Find Pythagorean triples (x, y, z) such that x**2 + y**2 == z**2
and x + y + z == n
.
import math
from itertools import combinations
def triples(n):
for x, y in combinations(range(1, n), 2):
z = n - x - y