import re
s = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
words = re.sub("[^\w]", " ", s).split()
# если просто найти все минимальные слова
t = [v for v in words if len(v) == len(min(words))]
# если все слова надо разделить по длине
from itertools import groupby
t1 = {k:list(v) for k,v in groupby(sorted(words, key=len), len)}
print(t1[min(t1)], t)
test.py:
from selenium import webdriver
driver = webdriver.Chrome()
test1.py:
from test import driver
return element.click()
#config.clear() #Если раскомментировать эту строку, тогда вывод будет как в варианте 1, т.е. не правильный.
== True- это лишнее.
config.clear() #Если список очищается тут, тогда значения нормальные, как в варианте 2
# Создаем словарь где опредляем, приоритет каждого элемента
dict_to_sorting = {
1: 1,
2: 2,
3: 3,
4: 4,
# и так далее
'a': 10,
'b': 11
# и так далее
}
list_for_sorting = [2, 3, 4, 'b', 'a', 1, 2]
result = sorted(
# Что сортируем
list_for_sorting,
# Функция опредляющее правило получения значения для каждого элемента
key=lambda x: dict_to_sorting[x],
# Флаг, указывающий следует ли производить сортировку в обратном порядке.
reverse=True
)
print(result)
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
def get_element(self, path_type, element_path, custom_time_out=None,):
"""
:param path_type: тип локатора
:param element_path: путь элемента
:return:
"""
__type = {
'xpath': By.XPATH,
'css': By.CSS_SELECTOR,
'id': By.ID,
'class': By.CLASS_NAME
}
if custom_time_out is not None:
time_out = custom_time_out
else:
time_out = self.time_out
return WebDriverWait(self.driver, time_out).until(expected_conditions.presence_of_element_located((__type.get(path_type), element_path)))
"//option[contains(text(), 'Продам')]/parent::select"
from multiprocessing import Process
def test(dbname, order):
connect = get_couchdb_session(dbname=dbname)
for dbname in base_list:
thread = Process(target=test, args=(dbname, *args))
thread.start()
def get_something_specific(self, *args):
pass
api.get_something_specific = get_something_specific
b = {randint(1, 1000) for _ in range(100)}
b
{513, 17, 25, 26, 28, 46, 52, 54, 62, 63, 65, 581, 582, 72, 80, 82, 600, 601, 618, 625, 118, 639, 132, 649, 651, 142, 661, 662, 151, 168, 172, 685, 188, 701, 195, 708, 205, 211, 724, 214, 730, 741, 238, 760, 762, 255, 256, 767, 771, 779, 791, 792, 793, 280, 806, 295, 822, 311, 833, 835, 839, 331, 848, 343, 860, 349, 350, 367, 383, 897, 386, 900, 912, 914, 408, 419, 420, 935, 936, 425, 939, 430, 943, 432, 433, 435, 949, 956, 450, 452, 973, 976, 477, 478, 995, 486, 497, 501, 508}
a = {randint(1, 1000) for _ in range(100)}
a
{517, 7, 532, 534, 544, 35, 551, 49, 54, 571, 75, 78, 592, 601, 92, 114, 634, 123, 638, 128, 643, 653, 143, 149, 669, 162, 163, 168, 174, 176, 713, 207, 208, 209, 216, 730, 742, 235, 243, 758, 761, 773, 782, 784, 786, 281, 795, 798, 811, 308, 316, 320, 832, 322, 324, 842, 845, 359, 877, 367, 885, 379, 381, 902, 391, 906, 394, 910, 919, 924, 928, 930, 935, 936, 425, 941, 432, 952, 444, 447, 963, 458, 971, 466, 473, 986, 480, 996, 1000, 503, 504, 506}
a.intersection(b)
{935, 168, 936, 425, 367, 432, 54, 601, 730}
# Если требуется порядок
a = [randint(1, 1000) for _ in range(100)]
b = [randint(1, 1000) for _ in range(100)]
[v for v in a if v in b]
[9, 866, 611, 981, 775, 197, 813, 337, 78]