set()'s .intersection for list and str

This commit is contained in:
Stefan Harmuth 2022-12-03 08:05:45 +01:00
parent c55d36380b
commit 87ead88610
2 changed files with 15 additions and 9 deletions

View File

@ -1,4 +1,5 @@
requests~=2.26.0
bs4~=0.0.1
beautifulsoup4~=4.10.0
setuptools~=56.0.0
beautifulsoup4==4.11.1
fishhook~=0.2.5
requests==2.28.1
setuptools==65.6.3

View File

@ -2,8 +2,9 @@ import datetime
import inspect
import os.path
import sys
from fishhook import hook
from functools import wraps
from typing import Any, Union, List
from typing import Any
def get_script_dir(follow_symlinks: bool = True) -> str:
@ -78,9 +79,13 @@ def cache(func):
return newfunc
def list_intersection(*args) -> list:
ret = set(args[0])
for l in args[1:]:
ret = ret.intersection(l)
@hook(list)
def intersection(self, *args) -> list:
ret = set(self).intersection(*args)
return list(ret)
return list(ret)
@hook(str)
def intersection(self, *args) -> str:
ret = set(self).intersection(*args)
return "".join(list(ret))