def flatten(x):
if isinstance(x, list):
for q in x:
yield from flatten(q)
else:
yield x
>>> list(flatten([1,2,3, [1,2, [3, [[[[4]]]]]]]))
[1, 2, 3, 1, 2, 3, 4]
def f(t):
i, l = t
print(f"{l=} {i=}")
with ThreadPoolExecutor() as pool:
for _ in pool.map(f, enumerate(["link1", "link2"])):
pass
from collections import deque
from concurrent.futures import ThreadPoolExecutor
def load_proxies():
with open('proxy.txt') as f:
return deque([row.strip() for row in f])
def get_article(proxies, link):
proxy = proxies.popleft()
try:
print("working with proxy", proxy, link)
finally:
proxies.append(proxy)
def main():
proxies = load_proxies()
with ThreadPoolExecutor(max_workers=50) as pool:
pool.map(lambda link: get_article(proxies, link), ["link1", "link2"])
if __name__ == "__main__":
main()
'98 243.00'.replace(' ', '')
re.sub("\s+", "", '98 243.00')
"".join(x for x in '98 243.00' if x.isdigit() or x in {"-", "."})
comm -12 <(sort --parallel=4 1.txt) <(sort --parallel=4 2.txt) > some_output_file.txt
и не совсем понимаю необходимости чтения книг.