group-and-iter-everything


Namegroup-and-iter-everything JSON
Version 0.18 PyPI version JSON
download
home_pagehttps://github.com/hansalemaos/group_and_iter_everything
SummaryMany useful groupby / itertools functions
upload_time2023-02-08 06:52:54
maintainer
docs_urlNone
authorJohannes Fischer
requires_python
licenseMIT
keywords itertools groupby
VCS
bugtrack_url
requirements check_if_nan ctypes_window_info dict_merger_keep_all divide_region_into_rectangles flatten_any_dict_iterable_or_whatsoever flatten_everything flexible_partial get_consecutive_filename hexintcalc intersection_grouper isiter kthread_sleep locate_pixelcolor nestednop numexpr numpy rect_intersection regex threadingbatch tolerant_isinstance xxhash
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# Many useful groupby / itertools functions 



```python

pip install group-and-iter-everything

```

### update 2023-02-08 

```python

from group_and_iter_everything import *



# sort dict keys

print(dict(iter_sorted_dict_keys(di={1: 2, 11: 2, 2: 2})))

# output: {1: 2, 2: 2, 11: 2}

###########################################################

# normalize list of lists (same length)

l = [[1, 2, 3], [4, 5], [1]]

print(list(iter_normalized_list_of_lists(l, fillv=None)))

# output: [[1, 2, 3], [4, 5, None], [1, None, None]]

###########################################################

# transpose list (very useful for coordinates [x,y]])

l = [(1, 2), (3, 4), (4, 5)]

print(list(iter_transposed_list_of_lists(l)))



l = [[1, 3, 4], [2, 4, 5]]

print(list(iter_transposed_list_of_lists(l)))



# output:

# [[1, 3, 4], [2, 4, 5]]

# [[1, 2], [3, 4], [4, 5]]

###########################################################

# Drop duplicates in nested lists

l2 = [[1, 2], [1, 2], 7, [3, 8], [3, 8]]

print(list(iter_droped_nested_duplicates(l2)))

# output: [[1, 2], 7, [3, 8]]

###########################################################

# Sort dict by value

di1 = {1: "bu", 11: 2.0, 2: "anna"}

di2 = {1: "bu", 11: "bax", 2: "anna"}

print(list(iter_sorted_dict_keys_values(di1)))

print(list(iter_sorted_dict_keys_values(di2)))



# output:

# [(11, 2.0), (2, 'anna'), (1, 'bu')]

# [(2, 'anna'), (11, 'bax'), (1, 'bu')]

###########################################################

# Group a text by Unicode names

text = """Unidecode is not a replacement for fully supporting Unicode for strings in your program. There are a number of caveats that come with its use, especially when its output is directly visible to users. Please read the rest of this README before using Unidecode in your project.

In most of examples listed above you could represent Unicode characters as ??? or \15BA\15A0\1610, to mention two extreme cases. But that’s nearly useless to someone who actually wants to read what the text says."""

tu = groupby_unicode_name(

    text, continue_on_exceptions=True, withindex=False, withvalue=True

)

print(tu)

# output:

# ....

# 'LATIN SMALL LETTER B': ['b', 'b', 'b', 'b'],

# 'LATIN SMALL LETTER V': ['v', 'v', 'v'],

# 'LATIN SMALL LETTER W': ['w', 'w', 'w', 'w', 'w', 'w'],

# 'COMMA': [',', ','],

# 'LATIN CAPITAL LETTER P': ['P'],

# 'LATIN CAPITAL LETTER R': ['R'],

# ....

###########################################################

# Call different functions in a thread, and get the result as a dict.

import requests



def testx(

    testnumber, *args, **kwargs

):  # a threaded function must have *args, **kwargs and can't have the keyword argument _starttime.

    # If your function doesn't have *args and **kwargs, add it.



    print(f"start {testnumber}")

    return random.randrange(1, 30)





def reqd(

    u, *args, **kwargs

):  # don't forget: You have to add  *args, **kwargs to the threaded function

    return requests.get(u)





urls = [

    "https://github.com/hansalemaos/a_pandas_ex_regex_enhancements#start-of-content",

    "https://github.com/",

]

# This is how you have to build the list for Threading

# (1, testx, ("halkl",), {"vds": 3})

# 1 - name of the thread, must be unique!

# testx - the function

# ("halkl",) - args (if the function doesn't have args, use ()

# {"vds": 3} - kwargs (if the function doesn't have kwargs, use {}

no_fu_args_kwargs = [

    (1, testx, ("halkl",), {"vds": 3}),

    (2, testx, ("hxxalkl",), {"vxxds": 3}),

]

alle = len(no_fu_args_kwargs)

for ini, i in enumerate(urls):  # appending other threads

    no_fu_args_kwargs.append((alle + ini, reqd, (), {"u": i}))



resi = execute_as_thread(

    no_fu_args_kwargs,

    wait_to_complete=True,

    # recommended, if you don't want to wait the function returns None, but you can find your results in group_and_iter_everything.threadingbatch.results, once all threads are done, the key "done" will change to True

    return_dict=True,  # Works only when wait_to_complete is True

    threadtlimit=2,  # Limit of threads

    # number of simultaneously executed threads

    timeout=4,

    # call Kthread.kill after n seconds, if your function uses sleep, it is better to use this sleep function: from kthread_sleep import sleep

    sleepafterkill=0.02,  # sleep time after calling Kthread.kill # don't use 0.0

    sleepafterstart=0.02,  # sleep time after starting a thread  # don't use 0.0

    ignore_exceptions=False,  # You can go on when there are Exceptions

    verbose=False,

)



# output:

# resi

# Out[3]:

# defaultdict(<function threadingbatch.<lambda>()>,

#             {'done': True,

#              '3': defaultdict(<function threadingbatch.<lambda>()>,

#                          {'results': <Response [200]>,

#                           'realstart': 1675824200.253053}),

#              '2': defaultdict(<function threadingbatch.<lambda>()>,

#                          {'results': <Response [200]>,

#                           'realstart': 1675824200.2320704}),

#              '1': defaultdict(<function threadingbatch.<lambda>()>,

#                          {'results': 18, 'realstart': 1675824200.1902106})})

#

#



# Executing without waiting for the results:



resi = execute_as_thread(

    no_fu_args_kwargs,

    wait_to_complete=False,

    # you can find the results in group_and_iter_everything.threadingbatch.results, once all threads are done, the key "done" will change to True

    return_dict=True,

    threadtlimit=2,

    timeout=4,

    sleepafterkill=0.02,

    sleepafterstart=0.02,

    ignore_exceptions=False,

    verbose=False,

)



# print(threadingbatch.results)

#

# Not finished yet ('done': False)

#

# defaultdict(<function <lambda> at 0x0000000012A134C0>, {'done': False, '3': defaultdict(<function <lambda> at 0x0000000012A134C0>, {'results': None, 'realstart': None}), '2': defaultdict(<function <lambda> at 0x0000000012A134C0>, {'results': None, 'realstart': None}), '1': defaultdict(<function <lambda> at 0x0000000012A134C0>, {'results': None, 'realstart': None})})

###########################################################

# rjust/ljust a list of strings



text = """

Read the running tests and linters section of our documentation to learn how to test your code. For cross-browser 

""".split()

list(

    iter_list_ljust_rjust(

        l=[1, 2] + text,  # can contain any dtype

        ljust=None,  # if None and getmax is True -> the longest str will be used

        ljustchr="-",  # fill with char

        rjust=None,  # if None and getmax is True -> the longest str will be used

        rjustchr="-",  # fill with char



        getmax=True,

    )

)

list(

    iter_list_ljust_rjust(

        l=[1, 2] + text, ljust=0, ljustchr="-", rjust=None, rjustchr="-", getmax=True

    )

)

list(

    iter_list_ljust_rjust(

        l=[1, 2] + text, ljust=None, ljustchr="-", rjust=0, rjustchr="-", getmax=True

    )

)

list(

    iter_list_ljust_rjust(

        l=[1, 2] + text, ljust=0, ljustchr="-", rjust=12, rjustchr="y", getmax=False

    )

)

list(

    iter_list_ljust_rjust(

        l=[1, 2] + text, ljust=15, ljustchr="x", rjust=0, rjustchr="-", getmax=False

    )

)





# output:

# ['------------1', '------------2', '---------Read', '----------the', '------running', '--------tests', '----------and', '------linters', '------section', '-----------of', '----------our', 'documentation', '-----------to', '--------learn', '----------how', '-----------to', '---------test', '---------your', '--------code.', '----------For', 'cross-browser']

# ['------------1', '------------2', '---------Read', '----------the', '------running', '--------tests', '----------and', '------linters', '------section', '-----------of', '----------our', 'documentation', '-----------to', '--------learn', '----------how', '-----------to', '---------test', '---------your', '--------code.', '----------For', 'cross-browser']

# ['1------------', '2------------', 'Read---------', 'the----------', 'running------', 'tests--------', 'and----------', 'linters------', 'section------', 'of-----------', 'our----------', 'documentation', 'to-----------', 'learn--------', 'how----------', 'to-----------', 'test---------', 'your---------', 'code.--------', 'For----------', 'cross-browser']

# ['yyyyyyyyyyy1', 'yyyyyyyyyyy2', 'yyyyyyyyRead', 'yyyyyyyyythe', 'yyyyyrunning', 'yyyyyyytests', 'yyyyyyyyyand', 'yyyyylinters', 'yyyyysection', 'yyyyyyyyyyof', 'yyyyyyyyyour', 'documentation', 'yyyyyyyyyyto', 'yyyyyyylearn', 'yyyyyyyyyhow', 'yyyyyyyyyyto', 'yyyyyyyytest', 'yyyyyyyyyour', 'yyyyyyycode.', 'yyyyyyyyyFor', 'cross-browser']

# ['1xxxxxxxxxxxxxx', '2xxxxxxxxxxxxxx', 'Readxxxxxxxxxxx', 'thexxxxxxxxxxxx', 'runningxxxxxxxx', 'testsxxxxxxxxxx', 'andxxxxxxxxxxxx', 'lintersxxxxxxxx', 'sectionxxxxxxxx', 'ofxxxxxxxxxxxxx', 'ourxxxxxxxxxxxx', 'documentationxx', 'toxxxxxxxxxxxxx', 'learnxxxxxxxxxx', 'howxxxxxxxxxxxx', 'toxxxxxxxxxxxxx', 'testxxxxxxxxxxx', 'yourxxxxxxxxxxx', 'code.xxxxxxxxxx', 'Forxxxxxxxxxxxx', 'cross-browserxx']

###########################################################

# How to avoid multiple break conditions like in this example

done = False

counter = 0

for i in range(1, 6, 1):  # 1st loop

    print("i:", i)

    for j in range(1, 11, 2):  # 2nd loop

        print("   i, j:", i, j)

        for k in range(1, 21, 4):  # 3rd loop

            print("      i,j,k:", i, j, k)

            if i % 3 == 0 and j % 3 == 0 and k % 3 == 0:

                done = True

                break  # breaking from 3rd loop

        if done:

            break  # breaking from 2nd loop

    if done:

        break  # breaking from 1st loop

    print(counter)

# print(i,j,k)

# 3 3 9



# Break any nested loop with a condition

def cond(

    i, j, k

):  # the function which checks every loop if the break condition is True

    return i % 3 == 0 and j % 3 == 0 and k % 3 == 0





alli = range(1, 6, 1), range(1, 11, 2), range(1, 21, 4)

for v in iter_with_breaking_condition(

    *alli,  # pass all iterables

    cond,  # function with the condition

    input_vars={

        "i": 0,

        "j": 0,

        "k": 1,

    },

    # the variables that need to be shared with the condition function, they don't have to exist yet

    output_var="outdiv3",  # the name of the output dict with all variables from input_vars

    delete_old=True,  # input_vars will be deleted

    clean_vars=True,  # input_vars will be deleted after finishing the execution

    print_vars=True,  # verbose

    counter="counter",  # like enumerate

):

    # you can access now all variables that you passed as input_vars as well as counter

    # You have to update them if they are part of the break condition

    it.i, it.j, it.k = v

    print(it.counter)

print(it.outdiv3)  # you can access the variable in output_var

# output

# print(it.outdiv3)

# {'i': 3, 'j': 3, 'k': 9}







# Another example

def cond(i, j, k):

    return i % 3 == 0 and j % 3 == 0 and k % 3 == 0





alli = [50, 50, 50] * 100, [150, 150, 150] * 100, [250, 250, 250] * 100

for r, g, b in iter_with_breaking_condition(

    *alli,

    lambda total: total > 10000,

    input_vars={"total": 0},

    output_var="out",

    delete_old=True,

    clean_vars=True,

    print_vars=True,

    counter="counter",

):

    # print(v)

    it.total = it.total + r + g + b

    print(it.counter)

print(it.out)



# output:

# print(it.out)

# {'total': 10350}

###########################################################

# Merge nested dicts and iterrate (keys/value pairs) without loosing data (values are joined and not overwritten)

people = {

    1: {"name": "John", "age": "27", "sex": "Male"},

    2: {"name": "Marie", "age": "22", "sex": "Female"},

    3: {"name": "Luna", "age": "24", "sex": "Female"},

    4: {

        "name": "Peter",

        "age": "29",

        "sex": ["Female", "Male"],

        1: "xx",

        "sex2": ("Female", "Male"),

    },

}



people3 = {

    1: {"namexxxxxxxxx": "John", "age": "27", "sex": "Male"},

    2: {"name": "Marie", "age": "22", "sex": "Female"},

    3: {"name": "Luna", "agexxxxxxxxxx": "24", "sex": "Female"},

    4: {

        "name": "Peter",

        "age": "29",

        "sex": ["Female", "Male"],

        1: "xx",

        "sex2": ("Female", "Male"),

    },

}

people2 = {

    11: {"name": "Johnaaa", "age": "2x337", "sex": "Maleooo"},

    21: {"name": "Mariexx", "age": "22", "sex": "Female"},

    13: {"name": "Luna", "age": "24444", "sex": "Feoomale"},

    14: {

        "name": "Peter",

        "age": "29",

        "sex": ["Female", "Male"],

        111: "xx",

        "sex2": ("Female", "Male"),

    },

}

d1 = {1: {"a": "A"}, 2: {"b": "B"}}



d2 = {2: {"c": "C"}, 3: {"d": ["D", "dd", "s"]}}



dict1 = {1: {"a": 1}, 2: {"b": 2}}



dict2 = {2: {"c": 222}, 3: {"d": {3, 6}}}



data2 = {"A": [4, 5, 6]}



for (

    keys,

    item,

) in iter_join_dicts_no_loss(people, people2, d1, d2, dict2, dict1, data2, people3):

    print(keys, item)



# output:

# ...

# (1, 14, 'sex', 1) Male

# (1, 14, 111) xx

# (1, 14, 'sex2', 0) Female

# (1, 14, 'sex2', 1) Male

# (2, 1, 'a') A

# (2, 2, 'b') B

# (3, 2, 'c') C

# (3, 3, 'd', 0) D

# (3, 3, 'd', 1) dd

# ...



###########################################################

# get free file names (enumeration)

for ini, fi in enumerate(

    iter_get_free_filenames(

        folder="f:\\testfiles", fileextension=".txt", leadingzeros=5

    )

):

    with open(fi, mode="w", encoding="utf-8") as f:

        f.write("")

    if ini == 5:

        break

    print(fi)



# output:

# f:\testfiles\00002.txt

# f:\testfiles\00003.txt

# f:\testfiles\00004.txt

# f:\testfiles\00005.txt

# f:\testfiles\00006.txt

#

###########################################################

# log split for iterables

for li in iter_log_split(list(range(20))):

    print(li)



# output:

# [0]

# [1, 2]

# [3, 4, 5]

# [6, 7, 8, 9]

# [10, 11, 12, 13, 14]

# [15, 16, 17, 18, 19]

###########################################################

# Iterate through a nested dict (keys/value pairs) and update

# the values in the original dict

dictoriginal = data = {

    "level1": {

        "t1": {

            "s1": {"col1": 5, "col2": 4, "col3": 4, "col4": 9},

            "s2": {"col1": 1, "col2": 5, "col3": 4, "col4": 8},

            "s3": {"col1": 11, "col2": 8, "col3": 2, "col4": 9},

            "s4": {"col1": 5, "col2": 4, "col3": 4, "col4": 9},

        },

        "t2": {

            "s1": {"col1": 5, "col2": 4, "col3": 4, "col4": 9},

            "s2": {"col1": 1, "col2": 5, "col3": 4, "col4": 8},

            "s3": {"col1": 11, "col2": 8, "col3": 2, "col4": 9},

            "s4": {"col1": 5, "col2": 4, "col3": 4, "col4": 9},

        },

    }

}

for keys, value, setvalue in iter_nested_dict_to_edit(dictoriginal):

    if keys[-1] == "col1":

        if isinstance(value, int):

            if value > 4:

                setvalue(10000)

            else:

                setvalue(555)



# output:



# dictoriginal # changes the original dict!

# Out[16]:

# {'level1': {'t1': {'s1': {'col1': 10000, 'col2': 4, 'col3': 4, 'col4': 9},

#    's2': {'col1': 555, 'col2': 5, 'col3': 4, 'col4': 8},

#    's3': {'col1': 10000, 'col2': 8, 'col3': 2, 'col4': 9},

#    's4': {'col1': 10000, 'col2': 4, 'col3': 4, 'col4': 9}},

#   't2': {'s1': {'col1': 10000, 'col2': 4, 'col3': 4, 'col4': 9},

#    's2': {'col1': 555, 'col2': 5, 'col3': 4, 'col4': 8},

#    's3': {'col1': 10000, 'col2': 8, 'col3': 2, 'col4': 9},

#    's4': {'col1': 10000, 'col2': 4, 'col3': 4, 'col4': 9}}}}

###########################################################

args = [0], [1, 2, 3, 4], [5, 6], [7, 8, 9, 10, 11, 12, 13]

vad = list(iter_adjust_list_same_common_size_without_cutting(*args))

for indexno, itemno, multiplicated_item in vad:

    print(indexno, itemno, multiplicated_item)





# output:

# All items have been adjusted to 28 items (lowest common value that can be divided by the length of all lists), nothing has been cut off

# 0 0 [(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)]

# 0 1 [(1, 1, 1, 1, 1, 1, 1), (2, 2, 2, 2, 2, 2, 2), (3, 3, 3, 3, 3, 3, 3), (4, 4, 4, 4, 4, 4, 4)]

# 0 2 [(5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5), (6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6)]

# 0 3 [(7, 7, 7, 7), (8, 8, 8, 8), (9, 9, 9, 9), (10, 10, 10, 10), (11, 11, 11, 11), (12, 12, 12, 12), (13, 13, 13, 13)]

###########################################################

# same as iter_adjust_list_same_common_size_without_cutting, but zipped

vad2 = list(iter_adjust_list_same_common_size_without_cutting_zipped(*args))

for indexno, itemno, multiplicated_item in vad2:

    print(indexno, itemno, multiplicated_item, end="|")

# output:

# 0 0 [(0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,)]

# 0 1 [(1, 2, 3, 4), (1, 2, 3, 4), (1, 2, 3, 4), (1, 2, 3, 4), (1, 2, 3, 4), (1, 2, 3, 4), (1, 2, 3, 4)]

# 0 2 [(5, 6), (5, 6), (5, 6), (5, 6), (5, 6), (5, 6), (5, 6), (5, 6), (5, 6), (5, 6), (5, 6), (5, 6), (5, 6), (5, 6)]

# 0 3 [(7, 8, 9, 10, 11, 12, 13), (7, 8, 9, 10, 11, 12, 13), (7, 8, 9, 10, 11, 12, 13), (7, 8, 9, 10, 11, 12, 13)]

###########################################################

# returns a single list with adjusted length of every item

vad3 = list(iter_adjust_list_next_to_each_other_zipped(*args))

for multiplicated_item in vad3:

    print(multiplicated_item)



# output:

# [(0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,),

# (1, 2, 3, 4), (1, 2, 3, 4), (1, 2, 3, 4), (1, 2, 3, 4), (1, 2, 3, 4), (1, 2, 3, 4), (1, 2, 3, 4),

# (5, 6), (5, 6), (5, 6), (5, 6), (5, 6), (5, 6), (5, 6), (5, 6), (5, 6), (5, 6), (5, 6), (5, 6), (5, 6), (5, 6), (7, 8, 9, 10, 11, 12, 13),

# (7, 8, 9, 10, 11, 12, 13), (7, 8, 9, 10, 11, 12, 13), (7, 8, 9, 10, 11, 12, 13)]

###########################################################

# returns the first value in every list

vad4 = list(iter_transpose_ajusted_list(*args))

for multiplicated_item in vad4:

    print(multiplicated_item)

# output:

# (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

# 1, 1, 1, 1, 1, 1, 1, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 7, 7, 7, 7)

###########################################################

# equilibrates the quantity of each list item

vad5 = list(iter_equilibrate_zip(*args, maxresults=10))

for multiplicated_item in vad5:

    print(multiplicated_item, end=",")



# output:

# 0,0,5,6,0,0,1,2,3,4,5,6,0,0,5,6,0,7,8,9,10,11,12,13,0,1,2,3,4,5,6,0,0,5,6,0,0,1,2,3,4,5,6,0,0,5,6,7,8,9,10,11,12,13,0,0,1,2,3,4,5,6,0,0,5,6,0,0,1,2,3,4,5,6,0,7,8,9,10,11,12,13,0,5,6,0,0,1,2,3,4,5,6,0,0,5,6,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,

###########################################################

# Same as iter_equilibrate_zip but without flattening

vad6 = list(int_equilibrate_each_value_zip_keep_list(*args))

for multiplicated_item in vad6:

    print(multiplicated_item, end=",")

# output:

# [0],[0],[5, 6],[0],[0],[1, 2, 3, 4],[5, 6],[0],[0],[5, 6],[0],[7, 8, 9, 10, 11, 12, 13],[0],[1, 2, 3, 4],

# [5, 6],[0],[0],[5, 6],[0],[0],[1, 2, 3, 4],[5, 6],[0],[0],[5, 6],

# [7, 8, 9, 10, 11, 12, 13],[0],[0],[1, 2, 3, 4],[5, 6],[0],[0],[5, 6],[0]

# ,[0],[1, 2, 3, 4],[5, 6],[0],[7, 8, 9, 10, 11, 12, 13],[0],[5, 6],[0],

# [0],[1, 2, 3, 4],[5, 6],[0],[0],[5, 6],[0],[0],[1, 2, 3, 4],[5, 6],

# [7, 8, 9, 10, 11, 12, 13]

###########################################################

# get all ascii characters in different formats

list(iter_get_ascii_table())



# output:

# ...

# (b'0xf2', 242, b'\xc3\xb2'),

# (b'0xf3', 243, b'\xc3\xb3'),

# (b'0xf4', 244, b'\xc3\xb4'),

# (b'0xf5', 245, b'\xc3\xb5'),

# (b'0xf6', 246, b'\xc3\xb6'),

# ...

###########################################################

word, wordlist, wordlist_b = iter_string_to_utf16_byte(word="""ü'~ç)""")

# output:

# word

# Out[18]: b"\xfc'~\xe7)"



# wordlist

# Out[19]: [b'\xfc', b"'", b'~', b'\xe7', b')'] without empty bytes



# wordlist_b

# Out[20]: [b'\xfc', b'', b"'", b'', b'~', b'', b'\xe7', b'', b')', b''] # contains empty bytes

###########################################################

# Convert a list of utf-16-le to string

list(iter_utf16bytestostring([word]))

list(iter_utf16bytestostring([wordlist]))



# output:

# Out[21]: ["ü'~ç)"]

# Out[22]: ["ü'~ç)"]

###########################################################

# converts hex string to binary

pattern = ["0xff", "0xde", "0xdd", "0xaa"]

binconv = list(iter_hexstrings2bin(pattern))

print(binconv)

# convert to np array

binconvnp = np.frombuffer(b"".join(binconv), dtype="uint8")

print(binconvnp)



# output:

# [b'\xff', b'\xde', b'\xdd', b'\xaa']

# [255 222 221 170]

###########################################################

# convert hex to int / int to hex

print(list(iter_int_to_hex(range(13, 18))))

l = ["0xd", "0xe", "0xf", "0x10", "0x11"]

print(list(iter_hex_to_int(l)))



# output:

# ['0xd', '0xe', '0xf', '0x10', '0x11']

# [13, 14, 15, 16, 17]

###########################################################

# string to binary

ii = list(iter_str2bin(binbytes="baba", fill=8))



# output:

# [b'00000062', b'00000061', b'00000062', b'00000061']

###########################################################

# Use NumPy to split an iterable into n slices

a = np.array(list(range(20)))

for q in iter_split_with_np_in_n_slices(a, n=4):

    print(q)



# output:

# [0 1 2 3 4]

# [5 6 7 8 9]

# [10 11 12 13 14]

# [15 16 17 18 19]

###########################################################

# Use NumPy to split an iterable into n pieces with a certain size

for q in iter_split_with_np_in_pieces_of(a, n=4):

    print(q)





# output:

# [0 1 2 3]

# [4 5 6 7]

# [8  9 10 11]

# [12 13 14 15]

# [16 17 18 19]



for q in iter_split_with_np_in_pieces_of(a, n=10):

    print(q)



# output:

# [0 1 2 3 4 5 6 7 8 9]

# [10 11 12 13 14 15 16 17 18 19]

###########################################################

# convert data to void (raw)

for b in iter_convert_np_array_to_v(np.array([1, 2, 3]), contiguous=True):

    print(b)



# output:

# [b'\x01' b'\x00' b'\x00' b'\x00']

# [b'\x02' b'\x00' b'\x00' b'\x00']

# [b'\x03' b'\x00' b'\x00' b'\x00']

###########################################################

# apply a vectorized function against each item in a NumPy array

list(

    iter_npapply_vetor_function(

        np.array([10, 20, 30]), function=lambda x, y: re.sub("0", y, str(x)), y="222"

    )

)

bb = np.fromiter(iter_npapply_vetor_function(nparray=a, function=hex), dtype="O")

cc = list(iter_npapply_vetor_function(nparray=bb, function=int, base=16))



# output:

# ['1222', '2222', '3222']



# bb

# array(['0x0', '0x1', '0x2', '0x3', '0x4', '0x5', '0x6', '0x7', '0x8',

#        '0x9', '0xa', '0xb', '0xc', '0xd', '0xe', '0xf', '0x10', '0x11',

#        '0x12', '0x13'], dtype=object)



# cc

# Out[21]: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]

###########################################################

# Converts a NumPy array to one string

a1 = np_array_to_string(

    nparray=np.array([1, 2, 3]).astype("S8"),

    encoding="utf-8",

    errors="replace",

    replace0=True,

)

a2 = np_array_to_string(

    nparray=np.array([1, 2, 3]), encoding="utf-8", errors="replace", replace0=True

)

a3 = np_array_to_string(

    nparray=np.array([1, 2, 3]).astype("f"),

    encoding="utf-8",

    errors="replace",

    replace0=True,

)

# output





# a1

# Out[30]: '123'

# a2

# Out[31]: '\x01\x02\x03'

# a3

# Out[32]: '�?@@@'

###########################################################

# Search a sequence in a NumPy array

for k in iter_search_sequence_numpy(

    n := np.array(list(reversed(range(10)))), np.array([3, 2, 1])

):

    print(k, n[k])



# 6 3

# 7 2

# 8 1

###########################################################

# Finds the lowest common multiplier that every number/list can be divided

print(get_common_division_multiplier(3, 4, 9))

print(get_common_division_multiplier([3, 4, 9], [1, 2, 8, 4, 3], [2, 2]))



# output

# {36: {9: 4, 4: 9, 3: 12}, 108: {9: 12, 4: 27, 3: 36}}

# {30: {5: 6, 3: 10, 2: 15}}

###########################################################

# Copies a list, and shuffles it (original doesn’t change)

for k in iter_shuffle_copied_list([10, 11, 23]):

    print(k)



# output

# 23

# 10

# 11

###########################################################

# Shuffles a dict (original doesn’t change)



for key, item in shuffle_dict({1: 2, 5: 23, 323: 4}).items():

    print(key, item)



# output

# 323

# 4

# 5

# 23

# 1

# 2

###########################################################

# Normalizes lists by repeating

# Finds the lowest common multiplier that every number/list can be divided

# No item is left out

for key, item in cycle_list_until_every_list_fits(

    [4, 5, 6],

    [4, 1],

    maxresults=4,

    append=True,

).items():

    print(key, item)



for key, item in cycle_list_until_every_list_fits(

    [4, 5, 6],

    [2, 1],

    [44, 42, 21],

    maxresults=4,

    append=False,

).items():

    print(key, item)



#

# list(cycle_list_until_every_list_fits([4, 5, 6], [4,1], maxresults=4, append=True, ).items())

# Out[3]:

# [(6,

#   defaultdict(list, {0: [[4, 5, 6], [4, 5, 6]], 1: [[4, 1], [4, 1], [4, 1]]})),

#  (12,

#   defaultdict(list,

#               {0: [[4, 5, 6], [4, 5, 6], [4, 5, 6], [4, 5, 6]],

#                1: [[4, 1], [4, 1], [4, 1], [4, 1], [4, 1], [4, 1]]})),

#  (18,

#   defaultdict(list,

#               {0: [[4, 5, 6],

#                 [4, 5, 6],

#                 [4, 5, 6],

#                 [4, 5, 6],

#                 [4, 5, 6],

#                 [4, 5, 6]],

#                1: [[4, 1],

#                 [4, 1],

#                 [4, 1],

#                 [4, 1],

#                 [4, 1],

#                 [4, 1],

#                 [4, 1],

#                 [4, 1],

#                 [4, 1]]})),

#  (24,

#   defaultdict(list,

#               {0: [[4, 5, 6],

#                 [4, 5, 6],

#                 [4, 5, 6],

#                 [4, 5, 6],

#                 [4, 5, 6],

#                 [4, 5, 6],

#                 [4, 5, 6],

#                 [4, 5, 6]],

#                1: [[4, 1],

#                 [4, 1],

#                 [4, 1],

#                 [4, 1],

#                 [4, 1],

#                 [4, 1],

#                 [4, 1],

#                 [4, 1],

#                 [4, 1],

#                 [4, 1],

#                 [4, 1],

#                 [4, 1]]}))]

#

#



# list((cycle_list_until_every_list_fits([4, 5, 6], [2,1],[44,42,21], maxresults=2, append=False, ).items()))

# Out[5]:

# [(6,

#   defaultdict(list,

#               {0: [44, 42, 21, 44, 42, 21],

#                1: [4, 5, 6, 4, 5, 6],

#                2: [2, 1, 2, 1, 2, 1]})),

#  (12,

#   defaultdict(list,

#               {0: [44, 42, 21, 44, 42, 21, 44, 42, 21, 44, 42, 21],

#                1: [4, 5, 6, 4, 5, 6, 4, 5, 6, 4, 5, 6],

#                2: [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]}))]





###########################################################

# Sorts a dict by keys

sort_dict(di={2: 3, 54: 23, 1: 2})



# output

# {1: 2, 2: 3, 54: 23}

###########################################################

# Get random values from a list (no repetition)

iter_get_random_not_repeating_values(list_=list(range(10)), howmany=4)

# Out[6]: [6, 4, 3, 1]

iter_get_random_not_repeating_values(list_=list(range(10)), howmany=4)

# Out[7]: [5, 6, 7, 9]

###########################################################

# Get random values from a list (with repetition limit)

iter_get_random_values_with_max_rep(list_=list(range(3)), howmany=9, maxrep=4)

# Out[8]: [1, 1, 0, 0, 0, 2, 2, 2, 1]

iter_get_random_values_with_max_rep(list_=list(range(3)), howmany=9, maxrep=4)

# Out[9]: [2, 0, 0, 2, 2, 1, 0, 2, 1]

###########################################################

l = ["hallo", "12hal33", "42ha004942r", "4204h213", "hall000", "h", "cvwsA"]

for _ in (iter_sort_by_item_pos(l, 3,fillvalue='')):

    print(_)



# output:

# h

# 4204h213

# 12hal33

# 42ha004942r

# hallo

# hall000

# cvwsA

###########################################################

```



### update 2023-01-26 

```python

######################################################

seq=['hallo','hatschi', 'boot','bobo', 'baba', 'bdoo', 'float', 'boat' ]

print(groupby_element_pos(pos=0,seq=seq, continue_on_exceptions=True, withindex=False, withvalue=True))

# output: {'h': ['hallo', 'hatschi'], 'b': ['boot', 'bobo', 'baba', 'bdoo', 'boat'], 'f': ['float']}



print(groupby_element_pos(pos=1,seq=seq, continue_on_exceptions=True, withindex=False, withvalue=True))

# output: {'a': ['hallo', 'hatschi', 'baba'], 'o': ['boot', 'bobo', 'boat'], 'd': ['bdoo'], 'l': ['float']}



print(groupby_element_pos(pos=0,seq=seq, continue_on_exceptions=True, withindex=True, withvalue=True))

# output: {'h': [(0, 'hallo'), (1, 'hatschi')], 'b': [(2, 'boot'), (3, 'bobo'), (4, 'baba'), (5, 'bdoo'), (7, 'boat')], 'f': [(6, 'float')]}



print(groupby_element_pos(pos=1,seq=seq, continue_on_exceptions=True, withindex=True, withvalue=True))

# output: {'a': [(0, 'hallo'), (1, 'hatschi'), (4, 'baba')], 'o': [(2, 'boot'), (3, 'bobo'), (7, 'boat')], 'd': [(5, 'bdoo')], 'l': [(6, 'float')]}



######################################################

seq=['habichdich','hallo','hallihallo','hatschi', 'Game: halo' , 'boot','bobo', 'baba', 'bdoo', 'float', 'boat' ]

print(groupby_substring(substring='hallo',seq=seq, continue_on_exceptions=True, withindex=False, withvalue=True))

# output: {'hallo': ['hallo', 'hallihallo'], 'ha': ['hatschi'], 'hal': ['Game: halo'], '': ['boot', 'bobo', 'baba', 'bdoo', 'float', 'boat']}



print(groupby_substring(substring='hallo',seq=seq, continue_on_exceptions=True, withindex=True, withvalue=True))

# output: {'ha': [(0, 'habichdich'), (3, 'hatschi')], 'hallo': [(1, 'hallo'), (2, 'hallihallo')], 'hal': [(4, 'Game: halo')], '': [(5, 'boot'), (6, 'bobo'), (7, 'baba'), (8, 'bdoo'), (9, 'float'), (10, 'boat')]}



print(groupby_substring(substring='hallo',seq=seq, continue_on_exceptions=True, withindex=True, withvalue=False))

# output: {'ha': [0, 3], 'hallo': [1, 2], 'hal': [4], '': [5, 6, 7, 8, 9, 10]}



######################################################

print(find_common_start_string(seq=['ha','haaalo','hansa']))

# output: ha

######################################################

print(find_common_end_string(seq=['hax','haaaloax','hansax']))

# output: ax

######################################################

from pprint import pprint

res=group_windows_by_class_name()

pprint(res,width=25, compact=True)

# ...

# 'WindowsForms10.Window.20808.app.0.2780b98_r6_ad1': [WindowInfo(pid=18276, title='WindowsForms10.Window.20808.app.0.2780b98_r6_ad1', windowtext='', hwnd=203870, length=1, tid=14100, status='invisible', coords_client=(0, 278, 0, 464), dim_client=(278, 464), coords_win=(1453, 1731, 601, 1065), dim_win=(278, 464), class_name='WindowsForms10.Window.20808.app.0.2780b98_r6_ad1', path='C:\\Program Files\\Greenshot\\Greenshot.exe'),

#                                                      WindowInfo(pid=18276, title='WindowsForms10.Window.20808.app.0.2780b98_r6_ad1', windowtext='', hwnd=269452, length=1, tid=14100, status='invisible', coords_client=(0, 128, 0, 48), dim_client=(128, 48), coords_win=(1730, 1858, 847, 895), dim_win=(128, 48), class_name='WindowsForms10.Window.20808.app.0.2780b98_r6_ad1', path='C:\\Program Files\\Greenshot\\Greenshot.exe'),

#                                                      WindowInfo(pid=18276, title='WindowsForms10.Window.20808.app.0.2780b98_r6_ad1', windowtext='', hwnd=466062, length=1, tid=14100, status='invisible', coords_client=(0, 61, 0, 4), dim_client=(61, 4), coords_win=(1730, 1791, 669, 673), dim_win=(61, 4), class_name='WindowsForms10.Window.20808.app.0.2780b98_r6_ad1', path='C:\\Program Files\\Greenshot\\Greenshot.exe'),

#                                                      WindowInfo(pid=18276, title='WindowsForms10.Window.20808.app.0.2780b98_r6_ad1', windowtext='', hwnd=531594, length=1, tid=14100, status='invisible', coords_client=(0, 196, 0, 114), dim_client=(196, 114), coords_win=(1257, 1453, 919, 1033), dim_win=(196, 114), class_name='WindowsForms10.Window.20808.app.0.2780b98_r6_ad1', path='C:\\Program Files\\Greenshot\\Greenshot.exe'),

# ...

######################################################

res=group_windows_by_coords_client()

pprint(res,width=25, compact=True)

# ...

# (0,

#   1,

#   0,

#   1): [WindowInfo(pid=4264, title='GDI+ Hook Window Class', windowtext='G', hwnd=1973524, length=2, tid=18104, status='invisible', coords_client=(0, 1, 0, 1), dim_client=(1, 1), coords_win=(0, 1, 0, 1), dim_win=(1, 1), class_name='GDI+ Hook Window Class', path='C:\\Program Files\\Just Great Software\\RegexBuddy 4\\RegexBuddy4.exe'), WindowInfo(pid=7408, title='GDI+ Hook Window Class', windowtext='G', hwnd=196686, length=2, tid=7712, status='invisible', coords_client=(0, 1, 0, 1), dim_client=(1, 1), coords_win=(0, 1, 0, 1), dim_win=(1, 1), class_name='GDI+ Hook Window Class', path='C:\\Program Files (x86)\\ClipAngel 1.94\\ClipAngel.exe'), WindowInfo(pid=8188, title='GDI+ Hook Window Class', windowtext='G', hwnd=660968, length=2, tid=16892, status='invisible', coords_client=(0, 1, 0, 1), dim_client=(1, 1), coords_win=(0, 1, 0, 1), dim_win=(1, 1), class_name='GDI+ Hook Window Class', path='C:\\Windows\\explorer.exe'), WindowInfo(pid=11824, title='GDI+ Hook Window Class', windowtext='G', hwnd=268808, length=2, tid=1344, status='invisible', coords_client=(0, 1, 0, 1), dim_client=(1, 1), coords_win=(0, 1, 0, 1), dim_win=(1, 1), class_name='GDI+ Hook Window Class', path='C:\\Program Files\\Notepad++\\notepad++.exe'), WindowInfo(pid=18276, title='GDI+ Hook Window Class', windowtext='G', hwnd=203884, length=2, tid=16940, status='invisible', coords_client=(0, 1, 0, 1), dim_client=(1, 1), coords_win=(0, 1, 0, 1), dim_win=(1, 1), class_name='GDI+ Hook Window Class', path='C:\\Program Files\\Greenshot\\Greenshot.exe'), WindowInfo(pid=19288, title='GDI+ Hook Window Class', windowtext='G', hwnd=330702, length=2, tid=5068, status='invisible', coords_client=(0, 1, 0, 1), dim_client=(1, 1), coords_win=(0, 1, 0, 1), dim_win=(1, 1), class_name='GDI+ Hook Window Class', path='C:\\Program Files (x86)\\Microsoft\\Skype for Desktop\\Skype.exe'), WindowInfo(pid=19324, title='GDI+ Hook Window Class', windowtext='G', hwnd=658766, length=2, tid=3760, status='invisible', coords_client=(0, 1, 0, 1), dim_client=(1, 1), coords_win=(0, 1, 0, 1), dim_win=(1, 1), class_name='GDI+ Hook Window Class', path='C:\\Program Files (x86)\\Microsoft\\Skype for Desktop\\Skype.exe')],

# ...

######################################################

res=group_windows_by_coords_win()

pprint(res,width=25, compact=True)

# ...

# (1912, 3848, -8, 1088): [WindowInfo(pid=16160, title='SunAwtFrame', windowtext='Python Console - dfdir', hwnd=1840892, length=23, tid=7456, status='visible', coords_client=(0, 1921, 0, 1080), dim_client=(1921, 1080), coords_win=(1912, 3848, -8, 1088), dim_win=(1936, 1096), class_name='SunAwtFrame', path='C:\\Program Files\\JetBrains\\PyCharm Community Edition 2020.3\\bin\\pycharm64.exe'),

#                          WindowInfo(pid=16160, title='SunAwtFrame', windowtext='dfdir – __init__.py Administrator', hwnd=529490, length=34, tid=7456, status='visible', coords_client=(0, 1921, 0, 1080), dim_client=(1921, 1080), coords_win=(1912, 3848, -8, 1088), dim_win=(1936, 1096), class_name='SunAwtFrame', path='C:\\Program Files\\JetBrains\\PyCharm Community Edition 2020.3\\bin\\pycharm64.exe'),

#                          WindowInfo(pid=16160, title='SunAwtFrame', windowtext='stopjogo – gp7.py Administrator', hwnd=4459518, length=32, tid=7456, status='visible', coords_client=(0, 1921, 0, 1080), dim_client=(1921, 1080), coords_win=(1912, 3848, -8, 1088), dim_win=(1936, 1096), class_name='SunAwtFrame', path='C:\\Program Files\\JetBrains\\PyCharm Community Edition 2020.3\\bin\\pycharm64.exe')],

# ...

######################################################

res=group_windows_by_dim_client()

pprint(res,width=25, compact=True)

# ...

# (61, 4): [WindowInfo(pid=18276, title='WindowsForms10.Window.20808.app.0.2780b98_r6_ad1', windowtext='', hwnd=466062, length=1, tid=14100, status='invisible', coords_client=(0, 61, 0, 4), dim_client=(61, 4), coords_win=(1730, 1791, 669, 673), dim_win=(61, 4), class_name='WindowsForms10.Window.20808.app.0.2780b98_r6_ad1', path='C:\\Program Files\\Greenshot\\Greenshot.exe'),

#           WindowInfo(pid=18276, title='WindowsForms10.Window.20808.app.0.2780b98_r6_ad1', windowtext='', hwnd=531600, length=1, tid=14100, status='invisible', coords_client=(0, 61, 0, 4), dim_client=(61, 4), coords_win=(1730, 1791, 719, 723), dim_win=(61, 4), class_name='WindowsForms10.Window.20808.app.0.2780b98_r6_ad1', path='C:\\Program Files\\Greenshot\\Greenshot.exe')],

# (67, 20): [WindowInfo(pid=8188, title='tooltips_class32', windowtext='', hwnd=65862, length=1, tid=8200, status='invisible', coords_client=(0, 67, 0, 20), dim_client=(67, 20), coords_win=(1740, 1807, 1049, 1069), dim_win=(67, 20), class_name='tooltips_class32', path='C:\\Windows\\explorer.exe')],

# ...

######################################################

res=group_windows_by_dim_win()

pprint(res,width=25, compact=True)

# ...

# (1936, 1096): [WindowInfo(pid=16160, title='SunAwtFrame', windowtext='Python Console - dfdir', hwnd=1840892, length=23, tid=7456, status='visible', coords_client=(0, 1921, 0, 1080), dim_client=(1921, 1080), coords_win=(1912, 3848, -8, 1088), dim_win=(1936, 1096), class_name='SunAwtFrame', path='C:\\Program Files\\JetBrains\\PyCharm Community Edition 2020.3\\bin\\pycharm64.exe'),

#                WindowInfo(pid=16160, title='SunAwtFrame', windowtext='stopjogo – gp7.py Administrator', hwnd=4459518, length=32, tid=7456, status='visible', coords_client=(0, 1921, 0, 1080), dim_client=(1921, 1080), coords_win=(1912, 3848, -8, 1088), dim_win=(1936, 1096), class_name='SunAwtFrame', path='C:\\Program Files\\JetBrains\\PyCharm Community Edition 2020.3\\bin\\pycharm64.exe')],

# (3840, 1080): [WindowInfo(pid=8188, title='Progman', windowtext='Program Manager', hwnd=131422, length=16, tid=6272, status='visible', coords_client=(0, 3840, 0, 1080), dim_client=(3840, 1080), coords_win=(0, 3840, 0, 1080), dim_win=(3840, 1080), class_name='Progman', path='C:\\Windows\\explorer.exe')],

# ...

######################################################

res=group_windows_by_path()

pprint(res,width=25, compact=True)



# ...

# 'C:\\Windows\\System32\\notepad.exe': [WindowInfo(pid=7708, title='IME', windowtext='Default IME', hwnd=6621606, length=12, tid=18480, status='invisible', coords_client=(0, 0, 0, 0), dim_client=(0, 0), coords_win=(0, 0, 0, 0), dim_win=(0, 0), class_name='IME', path='C:\\Windows\\System32\\notepad.exe'),

#                                        WindowInfo(pid=7708, title='MSCTFIME UI', windowtext='MSCTFIME UI', hwnd=3016006, length=12, tid=18480, status='invisible', coords_client=(0, 0, 0, 0), dim_client=(0, 0), coords_win=(0, 0, 0, 0), dim_win=(0, 0), class_name='MSCTFIME UI', path='C:\\Windows\\System32\\notepad.exe'),

#                                        WindowInfo(pid=7708, title='Notepad', windowtext='*Untitled - Notepad', hwnd=3998632, length=20, tid=18480, status='visible', coords_client=(0, 1022, 0, 578), dim_client=(1022, 578), coords_win=(242, 1280, 130, 767), dim_win=(1038, 637), class_name='Notepad', path='C:\\Windows\\System32\\notepad.exe')],

# 'C:\\Windows\\System32\\rundll32.exe': [WindowInfo(pid=6652, title='IME', windowtext='Default IME', hwnd=65686, length=12, tid=6656, status='invisible', coords_client=(0, 0, 0, 0), dim_client=(0, 0), coords_win=(0, 0, 0, 0), dim_win=(0, 0), class_name='IME', path='C:\\Windows\\System32\\rundll32.exe'),

#                                         WindowInfo(pid=6652, title='RunDLL', windowtext='', hwnd=1376404, length=1, tid=6656, status='invisible', coords_client=(0, 0, 0, 0), dim_client=(0, 0), coords_win=(78, 94, 78, 94), dim_win=(16, 16), class_name='RunDLL', path='C:\\Windows\\System32\\rundll32.exe'),

#                                         WindowInfo(pid=6652, title='rxDiagRuntimePumpWindowClass', windowtext='RxDiag Message Pump 2.1 Nov 23 2021 07:27:35', hwnd=65688, length=45, tid=6656, status='invisible', coords_client=(0, 360, 0, 57), dim_client=(360, 57), coords_win=(300, 680, 300, 400), dim_win=(380, 100), class_name='rxDiagRuntimePumpWindowClass', path='C:\\Windows\\System32\\rundll32.exe')],

# ...

######################################################

res=group_windows_by_pid()

pprint(res,width=25, compact=True)



# ...

# 3396: [WindowInfo(pid=3396, title='NVSVC64.DLL', windowtext='NvSvc', hwnd=197238, length=6, tid=9536, status='invisible', coords_client=(0, 1424, 0, 728), dim_client=(1424, 728), coords_win=(208, 1648, 208, 975), dim_win=(1440, 767), class_name='NVSVC64.DLL', path='C:\\Windows\\System32\\DriverStore\\FileRepository\\nv_dispi.inf_amd64_c0e159863e7afdde\\Display.NvContainer\\NVDisplay.Container.exe'),

#        WindowInfo(pid=3396, title='NvContainerWindowClass00000D44', windowtext='NvContainerWindowClass00000D44', hwnd=65632, length=31, tid=3400, status='invisible', coords_client=(0, 0, 0, 0), dim_client=(0, 0), coords_win=(0, 0, 0, 0), dim_win=(0, 0), class_name='NvContainerWindowClass00000D44', path='C:\\Windows\\System32\\DriverStore\\FileRepository\\nv_dispi.inf_amd64_c0e159863e7afdde\\Display.NvContainer\\NVDisplay.Container.exe'),

#        WindowInfo(pid=3396, title='UxdService', windowtext='UxdService', hwnd=131560, length=11, tid=9520, status='invisible', coords_client=(0, 1424, 0, 728), dim_client=(1424, 728), coords_win=(182, 1622, 182, 949), dim_win=(1440, 767), class_name='UxdService', path='C:\\Windows\\System32\\DriverStore\\FileRepository\\nv_dispi.inf_amd64_c0e159863e7afdde\\Display.NvContainer\\NVDisplay.Container.exe')],

# 3588: [WindowInfo(pid=3588, title='IME', windowtext='Default IME', hwnd=527634, length=12, tid=17620, status='invisible', coords_client=(0, 0, 0, 0), dim_client=(0, 0), coords_win=(0, 0, 0, 0), dim_win=(0, 0), class_name='IME', path='C:\\Program Files (x86)\\Microsoft\\Skype for Desktop\\Skype.exe'),

#        WindowInfo(pid=3588, title='crashpad_SessionEndWatcher', windowtext='', hwnd=986134, length=1, tid=17620, status='invisible', coords_client=(0, 130, 0, 10), dim_client=(130, 10), coords_win=(0, 136, 0, 39), dim_win=(136, 39), class_name='crashpad_SessionEndWatcher', path='C:\\Program Files (x86)\\Microsoft\\Skype for Desktop\\Skype.exe')],

# ...

######################################################

res=group_windows_by_status()

pprint(res,width=25, compact=True)



# ...

#{'invisible': [WindowInfo(pid=648, title='COMTASKSWINDOWCLASS', windowtext='Task Host Window', hwnd=131108, length=17, tid=688, status='invisible', coords_client=(0, 120, 0, 0), dim_client=(120, 0), coords_win=(0, 136, 0, 39), dim_win=(136, 39), class_name='COMTASKSWINDOWCLASS', path='C:\\Windows\\System32\\taskhostw.exe'),

#               WindowInfo(pid=648, title='CicLoaderWndClass', windowtext='', hwnd=65722, length=1, tid=700, status='invisible', coords_client=(0, 120, 0, 0), dim_client=(120, 0), coords_win=(0, 136, 0, 39), dim_win=(136, 39), class_name='CicLoaderWndClass', path='C:\\Windows\\System32\\taskhostw.exe'),

# ...

######################################################              



res=group_windows_by_tid()

pprint(res,width=25, compact=True)

# ...

# 19160: [WindowInfo(pid=18720, title='IME', windowtext='Default IME', hwnd=1252582, length=12, tid=19160, status='invisible', coords_client=(0, 0, 0, 0), dim_client=(0, 0), coords_win=(0, 0, 0, 0), dim_win=(0, 0), class_name='IME', path='C:\\Windows\\System32\\conhost.exe')],

# 20820: [WindowInfo(pid=1664, title='Chrome_WidgetWin_0', windowtext='', hwnd=3481304, length=1, tid=20820, status='invisible', coords_client=(0, 0, 0, 0), dim_client=(0, 0), coords_win=(0, 0, 0, 0), dim_win=(0, 0), class_name='Chrome_WidgetWin_0', path='C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe'),

#         WindowInfo(pid=1664, title='IME', windowtext='Default IME', hwnd=4396660, length=12, tid=20820, status='invisible', coords_client=(0, 0, 0, 0), dim_client=(0, 0), coords_win=(0, 0, 0, 0), dim_win=(0, 0), class_name='IME', path='C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe')]}

# ...

######################################################              

res=group_windows_by_title()

pprint(res,width=25, compact=True)

# ...

# '_SearchEditBoxFakeWindow': [WindowInfo(pid=8188, title='_SearchEditBoxFakeWindow', windowtext='', hwnd=2039638, length=1, tid=14128, status='invisible', coords_client=(0, 0, 0, 0), dim_client=(0, 0), coords_win=(0, 0, 0, 0), dim_win=(0, 0), class_name='_SearchEditBoxFakeWindow', path='C:\\Windows\\explorer.exe'),

#                              WindowInfo(pid=8188, title='_SearchEditBoxFakeWindow', windowtext='', hwnd=2825750, length=1, tid=4980, status='invisible', coords_client=(0, 0, 0, 0), dim_client=(0, 0), coords_win=(0, 0, 0, 0), dim_win=(0, 0), class_name='_SearchEditBoxFakeWindow', path='C:\\Windows\\explorer.exe'),

#                              WindowInfo(pid=18984, title='_SearchEditBoxFakeWindow', windowtext='', hwnd=266452, length=1, tid=15264, status='invisible', coords_client=(0, 0, 0, 0), dim_client=(0, 0), coords_win=(0, 0, 0, 0), dim_win=(0, 0), class_name='_SearchEditBoxFakeWindow', path='C:\\Windows\\explorer.exe')],

# 'crashpad_SessionEndWatcher': [WindowInfo(pid=3588, title='crashpad_SessionEndWatcher', windowtext='', hwnd=986134, length=1, tid=17620, status='invisible', coords_client=(0, 130, 0, 10), dim_client=(130, 10), coords_win=(0, 136, 0, 39), dim_win=(136, 39), class_name='crashpad_SessionEndWatcher', path='C:\\Program Files (x86)\\Microsoft\\Skype for Desktop\\Skype.exe'),

#                                WindowInfo(pid=12872, title='crashpad_SessionEndWatcher', windowtext='', hwnd=464830, length=1, tid=12688, status='invisible', coords_client=(0, 130, 0, 10), dim_client=(130, 10), coords_win=(0, 136, 0, 39), dim_win=(136, 39), class_name='crashpad_SessionEndWatcher', path='C:\\Program Files\\Krisp\\WebView2\\msedgewebview2.exe'),

#                                WindowInfo(pid=13436, title='crashpad_SessionEndWatcher', windowtext='', hwnd=4194640, length=1, tid=11620, status='invisible', coords_client=(0, 130, 0, 10), dim_client=(130, 10), coords_win=(0, 136, 0, 39), dim_win=(136, 39), class_name='crashpad_SessionEndWatcher', path='C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe'),

#                               WindowInfo(pid=20928, title='crashpad_SessionEndWatcher', windowtext='', hwnd=464914, length=1, tid=14920, status='invisible', coords_client=(0, 130, 0, 10), dim_client=(130, 10), coords_win=(0, 136, 0, 39), dim_win=(136, 39), class_name='crashpad_SessionEndWatcher', path='C:\\Program Files\\Krisp\\WebView2\\msedgewebview2.exe')],

# ...

######################################################    



res=group_windows_by_windowtext()

from pprint import pprint

pprint(res,width=25, compact=True)

# ...

# 'GitHub Desktop': [WindowInfo(pid=17556, title='Chrome_WidgetWin_1', windowtext='GitHub Desktop', hwnd=5966550, length=15, tid=12196, status='visible', coords_client=(0, 960, 0, 660), dim_client=(960, 660), coords_win=(669, 1629, 123, 783), dim_win=(960, 660), class_name='Chrome_WidgetWin_1', path='C:\\Users\\Gamer\\AppData\\Local\\GitHubDesktop\\app-3.1.4\\GitHubDesktop.exe')],

# 'Greenshot - the revolutionary screenshot utility': [WindowInfo(pid=18276, title='WindowsForms10.Window.8.app.0.2780b98_r6_ad1', windowtext='Greenshot - the revolutionary screenshot utility', hwnd=597088, length=49, tid=14100, status='invisible', coords_client=(0, 0, 0, 0), dim_client=(0, 0), coords_win=(-32000, -31840, -32000, -31972), dim_win=(160, 28), class_name='WindowsForms10.Window.8.app.0.2780b98_r6_ad1', path='C:\\Program Files\\Greenshot\\Greenshot.exe')],

# 'Hidden Window': [WindowInfo(pid=10876, title='HwndWrapper[Krisp.exe;;773b0141-7627-46a3-8fd7-70ae4b8b3669]', windowtext='Hidden Window', hwnd=399360, length=14, tid=19056, status='invisible', coords_client=(0, 1424, 0, 728), dim_client=(1424, 728), coords_win=(156, 1596, 156, 923), dim_win=(1440, 767), class_name='HwndWrapper[Krisp.exe;;773b0141-7627-46a3-8fd7-70ae4b8b3669]', path='C:\\Program Files\\Krisp\\Krisp.exe'),

#                   WindowInfo(pid=10876, title='HwndWrapper[Krisp.exe;;c309ef14-1945-423d-9140-f7e8760938b5]', windowtext='Hidden Window', hwnd=395536, length=14, tid=19056, status='invisible', coords_client=(0, 1424, 0, 728), dim_client=(1424, 728), coords_win=(208, 1648, 208, 975), dim_win=(1440, 767), class_name='HwndWrapper[Krisp.exe;;c309ef14-1945-423d-9140-f7e8760938b5]', path='C:\\Program Files\\Krisp\\Krisp.exe')],

# ...

######################################################    

v = [r"baba", r"baba", r"bubu", 3,4,5]

print(group_vars_by_hash(seq=v, continue_on_exceptions=True, withindex=False, withvalue=True))

# output: {-7914231873912742807: ['baba', 'baba'], -6908341703943681820: ['bubu'], 3: [3], 4: [4], 5: [5]}



print(group_vars_by_hash(seq=v, continue_on_exceptions=True, withindex=True, withvalue=True))

# output: {-7914231873912742807: [(0, 'baba'), (1, 'baba')], -6908341703943681820: [(2, 'bubu')], 3: [(3, 3)], 4: [(4, 4)], 5: [(5, 5)]}



######################################################    

files = [r"F:\00401 - Copy.jpg", r"F:\00401.jpg", r"F:\bw_pic.png", ]

group_files_by_hash(seq=files,continue_on_exceptions=True, withindex=True, withvalue=True)

# {'6d7ca5ec1deb81e4a127719a7b1b3328': ['F:\\00401 - Copy.jpg', 'F:\\00401.jpg'],

#  'fab1479078ac767ec468b28425f5069a': ['F:\\bw_pic.png']}

######################################################

```

## groupby stuff 



```python





######################################################

# Almost all groupby functions accept the kwargs: continue_on_exceptions, withindex, withvalue





# continue_on_exceptions=True - Exceptions are pulled, and each Exception gets its own group

print(groupby_can_be_divided_by(

    div=2, seq=(["1", 1, 3, 3, 3, 5, 3, 5, 22.22, *(3, 4), *[333, 4]]), continue_on_exceptions=True, withindex=False, withvalue=True

))

# output: {'EXCEPTION: not all arguments converted during string formatting': ['1'],

# False: [1, 3, 3, 3, 5, 3, 5, 22.22, 3, 333],

# True: [4, 4]}

 

######################################################

# withindex=True - Returns the index and the value of the input list:

print(groupby_can_be_divided_by(

    div=2, seq=(["1", 1, 3, 3, 3, 5, 3, 5, 22.22, *(3, 4), *[333, 4]]), continue_on_exceptions=True, withindex=True, withvalue=True

))



# output:{'EXCEPTION: not all arguments converted during string formatting': [(0, '1')], 

#  False: [(1, 1), (2, 3), (3, 3), (4, 3), (5, 5), (6, 3), (7, 5), (8, 22.22), (9, 3), (11, 333)], 

#  True: [(10, 4), (12, 4)]}





######################################################

# withvalue=False - Only the index of the input list is returned:

# output: {'EXCEPTION: not all arguments converted during string formatting': [0], 

# False: [1, 2, 3, 4, 5, 6, 7, 8, 9, 11],

# True: [10, 12]}

######################################################



```







```python

######################################################

print(list(iter_2_cycle_second_until_first_done(iter1=[3, 3, 4, 4], iter2=[1, 2])))

# output: [(3, 1), (3, 2), (4, 1), (4, 2)]

######################################################

print(groupby_euclid_dist(

    coord=(50, 100),

    seq=[(100, 100), (300, 500), (900, 23), (10, 10)],

    mindistance=0,

    maxdistance=500,

))



# output: {True: [(100, 100), (300, 500), (10, 10)], False: [(900, 23)]}

######################################################

print(groupby_string_length(

    seq=["dd", "b", "ff", "saaa"],

))



# output: {2: ['dd', 'ff'], 1: ['b'], 4: ['saaa']}

######################################################

print(group_values_in_flattened_nested_iter_and_count(seq=[1,2,3,4,[33,412,2,2,3], {(3,4), (1,4)}], continue_on_exceptions=True, withindex=False, withvalue=True

))

# output: {1: 2, 2: 3, 3: 3, 4: 3, 33: 1, 412: 1}

######################################################



print(groupby_type(seq=["dd", "b", "ff", "saaa", 1, 3, 5, 22.22, (3, 4), [333, 4]]))

# output: {<class 'str'>: ['dd', 'b', 'ff', 'saaa'], <class 'int'>: [1, 3, 5], <class 'float'>: [22.22], <class 'tuple'>: [(3, 4)], <class 'list'>: [[333, 4]]}

######################################################

print(groupby_frequency(

    seq=[

        "dd",

        "b",

        "ff",

        "saaa",

        1,

        3,

        3,

        3,

        5,

        "b",

        3,

        5,

        22.22,

        (3, 4),

        [333, 4],

    ]

))

# output: {1: ['dd', 'ff', 'saaa', 1, 22.22, (3, 4), [333, 4]], 2: ['b', 5, 'b', 5], 4: [3, 3, 3, 3]}

######################################################

print(groupby_division_remainder(

    div=2, seq=([1, 3, 3, 3, 5, 3, 5, 22.22, *(3, 4), *[333, 4]])

))

# output: {1: [1, 3, 3, 3, 5, 3, 5, 3, 333], 0.21999999999999886: [22.22], 0: [4, 4]}

######################################################

print(groupby_divisor(

    div=2, seq=([1, 3, 3, 3, 5, 3, 5, 22.22, *(3, 4), *[333, 4]])

))

# output: {0: [1], 1: [3, 3, 3, 3, 3], 2: [5, 5, 4, 4], 11.0: [22.22], 166: [333]}

######################################################

print(groupby_less_than_or_equal(

    number=2,

    seq=([1, 3, 3, 3, 5, 3,2,2, 5, 22.22, *(3, 4), *[333, 4]]),

    continue_on_exceptions=True,

    withindex=False,

))

# output: {True: [1, 2, 2], False: [3, 3, 3, 5, 3, 5, 22.22, 3, 4, 333, 4]}

######################################################

print(groupby_less_than(

    number=2,

    seq=([1, 3, 3, 3, 5, 3, 5, 22.22, *(3, 4), *[333, 4]]),

    continue_on_exceptions=True,

    withindex=False,

))

# output: {True: [1], False: [3, 3, 3, 5, 3, 5, 22.22, 3, 4, 333, 4]}

######################################################

print(groupby_bigger_than_or_equal(

    number=2,

    seq=([1, 3, 3, 3, 5, 3, 2,2,2,5, 22.22, *(3, 4), *[333, 4]]),

    continue_on_exceptions=True,

    withindex=False,

))

# output: {False: [1], True: [3, 3, 3, 5, 3, 2, 2, 2, 5, 22.22, 3, 4, 333, 4]}

######################################################

print(groupby_bigger_than(

    number=2,

    seq=(["1", 1, 3, 3, 3, 5, 3, 5, 22.22, *(3, 4), *[333, 4]]),

    continue_on_exceptions=True,

    withindex=False,

))

# output: {"EXCEPTION: '>' not supported between instances of 'str' and 'int'": ['1'], False: [1], True: [3, 3, 3, 5, 3, 5, 22.22, 3, 4, 333, 4]}

######################################################

print(groupby_equal(

    number=3,

    seq=(["1", 1, 3, 3, 3, 5, 3, 5, 22.22, *(3, 4), *[333, 4]]),

    continue_on_exceptions=True,

    withindex=False,

))

# output: {False: ['1', 1, 5, 5, 22.22, 4, 333, 4], True: [3, 3, 3, 3, 3]}

######################################################

print(groupby_regular_expression_matches(

    regexpressions=[r"^\d+$", '^A+$'],

    seq=([1, 3, 3, 3, 5, 3, 5,'AA', 'BB', 22.22, *(3, 4), *[333, 4]]),

    continue_on_exceptions=True,

    withindex=False,

))



# output: {True: [1, 3, 3, 3, 5, 3, 5, 'AA', 3, 4, 333, 4], False: ['BB', 22.22]}

######################################################

print(groupby_is_integer(

    seq=[2.0,1,1,3,5,3.0, 3.4,2.4,25.3], continue_on_exceptions=True, withindex=False, withvalue=True))

# output: {True: [2.0, 1, 1, 3, 5, 3.0], False: [3.4, 2.4, 25.3]}

######################################################

print(groupby_floor(

    seq=[1.0,1.1,1.2,1.3,1.9,1.8,2.0,1,1,3,5,3.0, 3.4,2.4,25.3], continue_on_exceptions=True, withindex=False, withvalue=True

))

# output: {1: [1.0, 1.1, 1.2, 1.3, 1.9, 1.8, 1, 1], 2: [2.0, 2.4], 3: [3, 3.0, 3.4], 5: [5], 25: [25.3]}

######################################################

print(groupby_ceil(

    seq=[1.0,1.1,1.2,1.3,1.9,1.8,2.0,1,1,3,5,3.0, 3.4,2.4,25.3], continue_on_exceptions=True, withindex=False, withvalue=True

))

# output: {1: [1.0, 1, 1], 2: [1.1, 1.2, 1.3, 1.9, 1.8, 2.0], 3: [3, 3.0, 2.4], 5: [5], 4: [3.4], 26: [25.3]}

######################################################

print(groupby_round(n=2,

    seq=[1.11111111,1.111222222,1.11113334,1.3,1.9,1.8,2.0,1,1,3,5,3.0, 3.4,2.4,25.3], continue_on_exceptions=True, withindex=False, withvalue=True

))

# output: {1.11: [1.11111111, 1.111222222, 1.11113334], 1.3: [1.3], 1.9: [1.9], 1.8: [1.8], 2.0: [2.0], 1: [1, 1], 3: [3, 3.0], 5: [5], 3.4: [3.4], 2.4: [2.4], 25.3: [25.3]}

######################################################

print(groupby_endswith(

    n=1,seq=['hallo', 'boot', 'baba', 'bdoo', 'flaot', 'mama' ], continue_on_exceptions=True, withindex=False, withvalue=True

))

# output: {'o': ['hallo', 'bdoo'], 't': ['boot', 'flaot'], 'a': ['baba', 'mama']}

######################################################

print(groupby_startswith(

    n=1,seq=['hallo', 'boot', 'baba', 'bdoo', 'flaot', 'hmama' ], continue_on_exceptions=True, withindex=False, withvalue=True

))

# output: {'h': ['hallo', 'hmama'], 'b': ['boot', 'baba', 'bdoo'], 'f': ['flaot']}



print(groupby_startswith(

    n=1,seq=['hallo', 'boot', 'baba', 'bdoo', 'flaot', 'hmama' ], continue_on_exceptions=True, withindex=True, withvalue=False

))

# output: {'h': [0, 5], 'b': [1, 2, 3], 'f': [4]}



print(groupby_startswith(

    n=1,seq=['hallo', 'boot', 'baba', 'bdoo', 'flaot', 'hmama' ], continue_on_exceptions=True, withindex=True, withvalue=True

))

# output: {'h': [(0, 'hallo'), (5, 'hmama')], 'b': [(1, 'boot'), (2, 'baba'), (3, 'bdoo')], 'f': [(4, 'flaot')]}

######################################################

print(groupby_first_occurrence_in_string(

    char='a',seq=['hallo', 'boot', 'baba', 'bdoo', 'flaot', 'hmama' ], continue_on_exceptions=True, withindex=False, withvalue=True

))

# output: {1: ['hallo', 'baba'], -1: ['boot', 'bdoo'], 2: ['flaot', 'hmama']}

######################################################

print(groupby_last_occurrence_in_string(

    char='a',seq=['hallo', 'boot', 'baba', 'bdoo', 'flaot', 'hmama' ], continue_on_exceptions=True, withindex=False, withvalue=True

))

# output: {1: ['hallo'], -1: ['boot', 'bdoo'], 3: ['baba'], 2: ['flaot'], 4: ['hmama']}

######################################################

text = '''One evening, a few days later, K. was walking along one of the corridors that separated his office from the main stairway—he was nearly the last one to leave for home that evening, there remained only a couple of workers in the light of a single bulb in the dispatch department—when he heard a sigh from behind a door which he had himself never opened but which he had always thought just led into a junk room. He stood in amazement and listened again to establish whether he might not be mistaken'''.split()

print(groupby_isalnum(

    seq=text, continue_on_exceptions=True, withindex=False, withvalue=True

))

# output: {True: ['One', 'a', 'few', 'days', 'was', 'walking', 'along', 'one', 'of', 'the', 'corridors', 'that', 'separated', 'his', 'office', 'from', 'the', 'main', 'was', 'nearly', 'the', 'last', 'one', 'to', 'leave', 'for', 'home', 'that', 'there', 'remained', 'only', 'a', 'couple', 'of', 'workers', 'in', 'the', 'light', 'of', 'a', 'single', 'bulb', 'in', 'the', 'dispatch', 'he', 'heard', 'a', 'sigh', 'from', 'behind', 'a', 'door', 'which', 'he', 'had', 'himself', 'never', 'opened', 'but', 'which', 'he', 'had', 'always', 'thought', 'just', 'led', 'into', 'a', 'junk', 'He', 'stood', 'in', 'amazement', 'and', 'listened', 'again', 'to', 'establish', 'whether', 'he', 'might', 'not', 'be', 'mistaken'], False: ['evening,', 'later,', 'K.', 'stairway—he', 'evening,', 'department—when', 'room.']}

######################################################

print(groupby_isalpha(

    seq=text, continue_on_exceptions=True, withindex=False, withvalue=True

))

# output: {True: ['One', 'a', 'few', 'days', 'was', 'walking', 'along', 'one', 'of', 'the', 'corridors', 'that', 'separated', 'his', 'office', 'from', 'the', 'main', 'was', 'nearly', 'the', 'last', 'one', 'to', 'leave', 'for', 'home', 'that', 'there', 'remained', 'only', 'a', 'couple', 'of', 'workers', 'in', 'the', 'light', 'of', 'a', 'single', 'bulb', 'in', 'the', 'dispatch', 'he', 'heard', 'a', 'sigh', 'from', 'behind', 'a', 'door', 'which', 'he', 'had', 'himself', 'never', 'opened', 'but', 'which', 'he', 'had', 'always', 'thought', 'just', 'led', 'into', 'a', 'junk', 'He', 'stood', 'in', 'amazement', 'and', 'listened', 'again', 'to', 'establish', 'whether', 'he', 'might', 'not', 'be', 'mistaken'], False: ['evening,', 'later,', 'K.', 'stairway—he', 'evening,', 'department—when', 'room.']}

######################################################

print(groupby_isascii(

    seq=text, continue_on_exceptions=True, withindex=False, withvalue=True

))

# output: {True: ['One', 'evening,', 'a', 'few', 'days', 'later,', 'K.', 'was', 'walking', 'along', 'one', 'of', 'the', 'corridors', 'that', 'separated', 'his', 'office', 'from', 'the', 'main', 'was', 'nearly', 'the', 'last', 'one', 'to', 'leave', 'for', 'home', 'that', 'evening,', 'there', 'remained', 'only', 'a', 'couple', 'of', 'workers', 'in', 'the', 'light', 'of', 'a', 'single', 'bulb', 'in', 'the', 'dispatch', 'he', 'heard', 'a', 'sigh', 'from', 'behind', 'a', 'door', 'which', 'he', 'had', 'himself', 'never', 'opened', 'but', 'which', 'he', 'had', 'always', 'thought', 'just', 'led', 'into', 'a', 'junk', 'room.', 'He', 'stood', 'in', 'amazement', 'and', 'listened', 'again', 'to', 'establish', 'whether', 'he', 'might', 'not', 'be', 'mistaken'], False: ['stairway—he', 'department—when']}

######################################################

print(groupby_isdecimal(

    seq=text, continue_on_exceptions=True, withindex=False, withvalue=True

))

# output: {False: ['One', 'evening,', 'a', 'few', 'days', 'later,', 'K.', 'was', 'walking', 'along', 'one', 'of', 'the', 'corridors', 'that', 'separated', 'his', 'office', 'from', 'the', 'main', 'stairway—he', 'was', 'nearly', 'the', 'last', 'one', 'to', 'leave', 'for', 'home', 'that', 'evening,', 'there', 'remained', 'only', 'a', 'couple', 'of', 'workers', 'in', 'the', 'light', 'of', 'a', 'single', 'bulb', 'in', 'the', 'dispatch', 'department—when', 'he', 'heard', 'a', 'sigh', 'from', 'behind', 'a', 'door', 'which', 'he', 'had', 'himself', 'never', 'opened', 'but', 'which', 'he', 'had', 'always', 'thought', 'just', 'led', 'into', 'a', 'junk', 'room.', 'He', 'stood', 'in', 'amazement', 'and', 'listened', 'again', 'to', 'establish', 'whether', 'he', 'might', 'not', 'be', 'mistaken']}

######################################################

print(groupby_isdigit(

    seq=text, continue_on_exceptions=True, withindex=False, withvalue=True

))

# output: {False: ['One', 'evening,', 'a', 'few', 'days', 'later,', 'K.', 'was', 'walking', 'along', 'one', 'of', 'the', 'corridors', 'that', 'separated', 'his', 'office', 'from', 'the', 'main', 'stairway—he', 'was', 'nearly', 'the', 'last', 'one', 'to', 'leave', 'for', 'home', 'that', 'evening,', 'there', 'remained', 'only', 'a', 'couple', 'of', 'workers', 'in', 'the', 'light', 'of', 'a', 'single', 'bulb', 'in', 'the', 'dispatch', 'department—when', 'he', 'heard', 'a', 'sigh', 'from', 'behind', 'a', 'door', 'which', 'he', 'had', 'himself', 'never', 'opened', 'but', 'which', 'he', 'had', 'always', 'thought', 'just', 'led', 'into', 'a', 'junk', 'room.', 'He', 'stood', 'in', 'amazement', 'and', 'listened', 'again', 'to', 'establish', 'whether', 'he', 'might', 'not', 'be', 'mistaken']}

######################################################

print(groupby_isidentifier(

    seq=text, continue_on_exceptions=True, withindex=False, withvalue=True

))

# output: {True: ['One', 'a', 'few', 'days', 'was', 'walking', 'along', 'one', 'of', 'the', 'corridors', 'that', 'separated', 'his', 'office', 'from', 'the', 'main', 'was', 'nearly', 'the', 'last', 'one', 'to', 'leave', 'for', 'home', 'that', 'there', 'remained', 'only', 'a', 'couple', 'of', 'workers', 'in', 'the', 'light', 'of', 'a', 'single', 'bulb', 'in', 'the', 'dispatch', 'he', 'heard', 'a', 'sigh', 'from', 'behind', 'a', 'door', 'which', 'he', 'had', 'himself', 'never', 'opened', 'but', 'which', 'he', 'had', 'always', 'thought', 'just', 'led', 'into', 'a', 'junk', 'He', 'stood', 'in', 'amazement', 'and', 'listened', 'again', 'to', 'establish', 'whether', 'he', 'might', 'not', 'be', 'mistaken'], False: ['evening,', 'later,', 'K.', 'stairway—he', 'evening,', 'department—when', 'room.']}

######################################################

print(groupby_islower(

    seq=text, continue_on_exceptions=True, withindex=False, withvalue=True

))

# output: {False: ['One', 'K.', 'He'], True: ['evening,', 'a', 'few', 'days', 'later,', 'was', 'walking', 'along', 'one', 'of', 'the', 'corridors', 'that', 'separated', 'his', 'office', 'from', 'the', 'main', 'stairway—he', 'was', 'nearly', 'the', 'last', 'one', 'to', 'leave', 'for', 'home', 'that', 'evening,', 'there', 'remained', 'only', 'a', 'couple', 'of', 'workers', 'in', 'the', 'light', 'of', 'a', 'single', 'bulb', 'in', 'the', 'dispatch', 'department—when', 'he', 'heard', 'a', 'sigh', 'from', 'behind', 'a', 'door', 'which', 'he', 'had', 'himself', 'never', 'opened', 'but', 'which', 'he', 'had', 'always', 'thought', 'just', 'led', 'into', 'a', 'junk', 'room.', 'stood', 'in', 'amazement', 'and', 'listened', 'again', 'to', 'establish', 'whether', 'he', 'might', 'not', 'be', 'mistaken']}

######################################################

print(groupby_isnumeric(

    seq=text, continue_on_exceptions=True, withindex=False, withvalue=True

))

# output: {False: ['One', 'evening,', 'a', 'few', 'days', 'later,', 'K.', 'was', 'walking', 'along', 'one', 'of', 'the', 'corridors', 'that', 'separated', 'his', 'office', 'from', 'the', 'main', 'stairway—he', 'was', 'nearly', 'the', 'last', 'one', 'to', 'leave', 'for', 'home', 'that', 'evening,', 'there', 'remained', 'only', 'a', 'couple', 'of', 'workers', 'in', 'the', 'light', 'of', 'a', 'single', 'bulb', 'in', 'the', 'dispatch', 'department—when', 'he', 'heard', 'a', 'sigh', 'from', 'behind', 'a', 'door', 'which', 'he', 'had', 'himself', 'never', 'opened', 'but', 'which', 'he', 'had', 'always', 'thought', 'just', 'led', 'into', 'a', 'junk', 'room.', 'He', 'stood', 'in', 'amazement', 'and', 'listened', 'again', 'to', 'establish', 'whether', 'he', 'might', 'not', 'be', 'mistaken']}

######################################################

print(groupby_isprintable(

    seq=text, continue_on_exceptions=True, withindex=False, withvalue=True

))

# output: {True: ['One', 'evening,', 'a', 'few', 'days', 'later,', 'K.', 'was', 'walking', 'along', 'one', 'of', 'the', 'corridors', 'that', 'separated', 'his', 'office', 'from', 'the', 'main', 'stairway—he', 'was', 'nearly', 'the', 'last', 'one', 'to', 'leave', 'for', 'home', 'that', 'evening,', 'there', 'remained', 'only', 'a', 'couple', 'of', 'workers', 'in', 'the', 'light', 'of', 'a', 'single', 'bulb', 'in', 'the', 'dispatch', 'department—when', 'he', 'heard', 'a', 'sigh', 'from', 'behind', 'a', 'door', 'which', 'he', 'had', 'himself', 'never', 'opened', 'but', 'which', 'he', 'had', 'always', 'thought', 'just', 'led', 'into', 'a', 'junk', 'room.', 'He', 'stood', 'in', 'amazement', 'and', 'listened', 'again', 'to', 'establish', 'whether', 'he', 'might', 'not', 'be', 'mistaken']}

######################################################

print(groupby_isspace(

    seq=text, continue_on_exceptions=True, withindex=False, withvalue=True

))

# output: {False: ['One', 'evening,', 'a', 'few', 'days', 'later,', 'K.', 'was', 'walking', 'along', 'one', 'of', 'the', 'corridors', 'that', 'separated', 'his', 'office', 'from', 'the', 'main', 'stairway—he', 'was', 'nearly', 'the', 'last', 'one', 'to', 'leave', 'for', 'home', 'that', 'evening,', 'there', 'remained', 'only', 'a', 'couple', 'of', 'workers', 'in', 'the', 'light', 'of', 'a', 'single', 'bulb', 'in', 'the', 'dispatch', 'department—when', 'he', 'heard', 'a', 'sigh', 'from', 'behind', 'a', 'door', 'which', 'he', 'had', 'himself', 'never', 'opened', 'but', 'which', 'he', 'had', 'always', 'thought', 'just', 'led', 'into', 'a', 'junk', 'room.', 'He', 'stood', 'in', 'amazement', 'and', 'listened', 'again', 'to', 'establish', 'whether', 'he', 'might', 'not', 'be', 'mistaken']}

######################################################

print(groupby_istitle(

    seq=text, continue_on_exceptions=True, withindex=False, withvalue=True

))

# output: {True: ['One', 'K.', 'He'], False: ['evening,', 'a', 'few', 'days', 'later,', 'was', 'walking', 'along', 'one', 'of', 'the', 'corridors', 'that', 'separated', 'his', 'office', 'from', 'the', 'main', 'stairway—he', 'was', 'nearly', 'the', 'last', 'one', 'to', 'leave', 'for', 'home', 'that', 'evening,', 'there', 'remained', 'only', 'a', 'couple', 'of', 'workers', 'in', 'the', 'light', 'of', 'a', 'single', 'bulb', 'in', 'the', 'dispatch', 'department—when', 'he', 'heard', 'a', 'sigh', 'from', 'behind', 'a', 'door', 'which', 'he', 'had', 'himself', 'never', 'opened', 'but', 'which', 'he', 'had', 'always', 'thought', 'just', 'led', 'into', 'a', 'junk', 'room.', 'stood', 'in', 'amazement', 'and', 'listened', 'again', 'to', 'establish', 'whether', 'he', 'might', 'not', 'be', 'mistaken']}

######################################################

print(groupby_isupper(

    seq=text, continue_on_exceptions=True, withindex=False, withvalue=True

))

# output: {False: ['One', 'evening,', 'a', 'few', 'days', 'later,', 'was', 'walking', 'along', 'one', 'of', 'the', 'corridors', 'that', 'separated', 'his', 'office', 'from', 'the', 'main', 'stairway—he', 'was', 'nearly', 'the', 'last', 'one', 'to', 'leave', 'for', 'home', 'that', 'evening,', 'there', 'remained', 'only', 'a', 'couple', 'of', 'workers', 'in', 'the', 'light', 'of', 'a', 'single', 'bulb', 'in', 'the', 'dispatch', 'department—when', 'he', 'heard', 'a', 'sigh', 'from', 'behind', 'a', 'door', 'which', 'he', 'had', 'himself', 'never', 'opened', 'but', 'which', 'he', 'had', 'always', 'thought', 'just', 'led', 'into', 'a', 'junk', 'room.', 'He', 'stood', 'in', 'amazement', 'and', 'listened', 'again', 'to', 'establish', 'whether', 'he', 'might', 'not', 'be', 'mistaken'], True: ['K.']}

######################################################

print(groupby_isin(value='1', seq=['1', '11', '2', 1,2,3,54,2], continue_on_exceptions=True, withindex=False, withvalue=True

))

# output: {True: ['1', '11'], False: ['2'], "EXCEPTION: argument of type 'int' is not iterable": [1, 2, 3, 54, 2]}

######################################################

import random

print(groupby_rectangle_intersects(

    rectangle=(0, 0, 100, 100),

    seq=[

        (

            g := random.randrange(1, 200),

            f := random.randrange(1, 200),

            g + 100,

            f + 100,

        )

        for _ in range(10)

    ],

    continue_on_exceptions=True,

    withindex=True,

))

# output: {False: [(0, (88, 157, 188, 257)), (1, (176, 63, 276, 163)), (2, (38, 102, 138, 202)), (4, (159, 145, 259, 245)), (5, (84, 199, 184, 299)), (6, (6, 160, 106, 260)), (7, (101, 133, 201, 233)), (9, (188, 148, 288, 248))], True: [(3, (27, 68, 127, 168)), (8, (2, 58, 102, 158))]}

######################################################

import pandas as pd

import math

import numpy as np

print(groupby_isna(

    seq=[pd.NA, np.nan, None, math.nan, 3,54,3,(22,34,412), {323,31}, [3312,3]],

    emptyiters = False,

    nastrings = False,

    emptystrings = False,

    emptybytes = False,

    continue_on_exceptions=True,

    withindex=False,

    withvalue=True,

))

# output: {True: [<NA>, nan, None, nan], False: [3, 54, 3, (22, 34, 412), {323, 31}, [3312, 3]]}

######################################################

import pandas as pd

import math

import numpy as np

print(groupby_isiter(

    seq=[pd.NA, np.nan, None, math.nan, 3, 54, 3, (22, 34, 412), {323, 31}, [3312, 3]],

    continue_on_exceptions=True,

    withindex=False,

    withvalue=True,

))

# output: {False: [<NA>, nan, None, nan, 3, 54, 3], True: [(22, 34, 412), {323, 31}, [3312, 3]]}

######################################################

import os

print(groupby_file_extension(

    seq=os.listdir(r'F:\gitrep\screenshots'), continue_on_exceptions=True, withindex=False, withvalue=True

))

# output: {'': ['.git', '.gitignore', 'color', 'debugdf', 'enumeratefiles', 'LICENSE', 'sortfiles'], '.png': ['144.png', '146.png', '2022-12-27 03_40_27-.png', '2022-12-27 03_49_27-.png', '2022-12-27 04_01_57-.png', '2022-12-27 04_02_09-.png', '2023-01-01 09_48_27-single_elements.png', 'add_methods.png', 'allcolors.png', 'asciiart.png', 'bluestacksauto.png', 'buttonsearch.png', 'collage.png', 'colorfind1.png', 'colorfind1xxx.png', 'colorfind2.png', 'colorfind3.png', 'colorfind4.png', 'cv2_putTrueTypeText_000000.png', 'cv2_putTrueTypeText_000001.png', 'cv2_putTrueTypeText_000002.png', 'cv2_putTrueTypeText_000003.png', 'cv2_putTrueTypeText_000004.png', 'cv2_putTrueTypeText_000005.png', 'cv2_putTrueTypeText_000006.png', 'cv2_putTrueTypeText_000007.png', 'cv2_putTrueTypeText_000008.png', 'cv2_putTrueTypeText_000009.png', 'cv2_putTrueTypeText_000010.png', 'cv2_putTrueTypeText_000011.png', 'cv2_putTrueTypeText_000012.png', 'cv2_putTrueTypeText_000013.png', 'cv2_putTrueTypeText_000014.png', 'cv2_putTrueTypeText_000015.png', 'cv2_putTrueTypeText_000017.png', 'dfresults.png', 'df_act01.png', 'df_act01_0.png', 'df_act02.png', 'df_act02_0.png', 'df_screen01.png', 'df_screen02.png', 'diff.png', 'findshapes_1.png', 'findshapes_2.png', 'findsquare.png', 'fromjsonorg.png', 'from_nested_dict.png', 'generateimgs.png', 'horizontal.png', 'imagediffsquare.png', 'jsonstring.png', 'json_from_file.png', 'json_from_file_sp.png', 'json_url.png', 'lines.png', 'merg1.png', 'merg2.png', 'merg3.png', 'merg4.png', 'merg5.png', 'merg6.png', 'merg7.png', 'noformat.png', 'norm.png', 'pandasconsoleplott.png', 'pandsnesteddicthtml.png', 'papag_00000000.png', 'papag_00000001.png', 'papag_00000002.png', 'papag_00000003.png', 'papag_00000004.png', 'papag_00000005.png', 'papag_00000006.png', 'papag_00000007.png', 'papag_00000008.png', 'papag_00000009.png', 'pic1.png', 'pic2.png', 'pic3.png', 'pic4.png', 'pic5.png', 'PROXY.png', 'randomscreenshots.png', 'rect1.png', 'rect2.png', 'resultsscreenshots.png', 'rotate1.png', 'rotate2.png', 'screencap1.png', 'screencap2.png', 'screencap3.png', 'screencap4.png', 'screenshotpandasseries.png', 'screenshotpandastable.png', 'seleniumkeys.png', 'sendevent_key.png', 'sendevent_key_video.png', 'sift.png', 'splitted0.png', 'splitted1.png', 'templatematching1.png', 'templatematching2.png', 'templatematching3.png', 'templatematching4.png', 'templatematching5.png', 'templatematching6.png', 'templatematching7.png', 'tensorflowscreen.png', 'tesseractscreen.png', 'testwholescreenshot.png', 'timemea.png', 'vc01.png', 'vc01_0.png', 'vertical.png', 'zoompics_0000001.png', 'zoompics_0000002.png', 'zoompics_0000003.png', 'zoompics_0000004.png', 'zoompics_0000005.png', 'zoompics_0000006.png', 'zoompics_0000007.png', 'zoompics_0000008.png'], '.css': ['df_style.css'], '.html': ['fromjsonorg.html', 'from_nested_dict.html', 'jsonstring.html', 'json_from_file.html', 'json_url.html', 'myhtml.html'], '.jpeg': ['splitted1.jpeg'], '.mp4': ['tesseractscreen.mp4']}

######################################################

from a_cv_imwrite_imread_plus import open_image_in_cv

print(groupby_color_qty_in_region(

    im=open_image_in_cv(

        "https://github.com/hansalemaos/screenshots/raw/main/colorfind1.png"

    ),

    colors=[(0, 0, 0)],

    startx=None,

    starty=None,

    stopx=None,

    stopy=None,

    rect_w=10,

    rect_h=10,

    continue_on_exceptions=True,

    withindex=False,

    withvalue=True,

))

# output: {100: [(0, 0, 10, 10), (0, 10, 10, 20), (0, 20, 10, 30), (0, 30, 10, 40), (0, 40, 10, 50), (0, 50, 10, 60), (0, 60, 10, 70), (0, 70, 10, 80), (0, 80, 10, 90), (0, 90, 10, 100), (0, 100, 10, 110), (0, 110, 10, 120), (0, 120, 10, 130), (0, 130, 10, 140), (0, 140, 10, 150), (0, 150, 10, 160), (0, 160, 10, 170), (0, 170, 10, 180), (0, 180, 10, 190), (0, 190, 10, 200), (10, 0, 20, 10), (10, 10, 20, 20), (10, 20, 20, 30), (10, 30, 20, 40), (10, 40, 20, 50), (10, 50, 20, 60), (10, 60, 20, 70), (10, 70, 20, 80), (10, 80, 20, 90), (10, 90, 20, 100), (10, 100, 20, 110), (10, 110, 20, 120), (10, 120, 20, 130), (10, 130, 20, 140), (10, 140, 20, 150), (10, 150, 20, 160), (10, 160, 20, 170), (10, 170, 20, 180), (10, 180, 20, 190), (10, 190, 20, 200), (20, 0, 30, 10), (20, 10, 30, 20), (20, 20, 30, 30), (20, 30, 30, 40), (20, 40, 30, 50), (20, 50, 30, 60), (20, 60, 30, 70), (20, 70, 30, 80), (20, 80, 30, 90), (20, 90, 30, 100), (20, 100, 30, 110), (20, 110, 30, 120), (20, 120, 30, 130), (20, 130, 30, 140), (20, 140, 30, 150), (20, 150, 30, 160), (20, 160, 30, 170), (20, 170, 30, 180), (20, 180, 30, 190), (20, 190, 30, 200), (30, 0, 40, 10), (30, 10, 40, 20), (30, 20, 40, 30), (30, 30, 40, 40), (30, 40, 40, 50), (30, 50, 40, 60), (30, 60, 40, 70), (30, 130, 40, 140), (30, 140, 40, 150), (30, 150, 40, 160), (30, 160, 40, 170), (30, 170, 40, 180), (30, 180, 40, 190), (30, 190, 40, 200), (40, 0, 50, 10), (40, 10, 50, 20), (40, 20, 50, 30), (40, 30, 50, 40), (40, 40, 50, 50), (40, 50, 50, 60), (40, 140, 50, 150), (40, 150, 50, 160), (40, 160, 50, 170), (40, 170, 50, 180), (40, 180, 50, 190), (40, 190, 50, 200), (50, 0, 60, 10), (50, 10, 60, 20), (50, 20, 60, 30), (50, 30, 60, 40), (50, 40, 60, 50), (50, 50, 60, 60), (50, 140, 60, 150), (50, 150, 60, 160), (50, 160, 60, 170), (50, 170, 60, 180), (50, 180, 60, 190), (50, 190, 60, 200), (60, 0, 70, 10), (60, 10, 70, 20), (60, 20, 70, 30), (60, 160, 70, 170), (60, 170, 70, 180), (60, 180, 70, 190), (60, 190, 70, 200), (70, 0, 80, 10), (70, 10, 80, 20), (70, 20, 80, 30), (70, 170, 80, 180), (70, 180, 80, 190), (70, 190, 80, 200), (80, 0, 90, 10), (80, 10, 90, 20), (80, 20, 90, 30), (80, 170, 90, 180), (80, 180, 90, 190), (80, 190, 90, 200), (90, 0, 100, 10), (90, 10, 100, 20), (90, 20, 100, 30), (90, 170, 100, 180), (90, 180, 100, 190), (90, 190, 100, 200), (100, 0, 110, 10), (100, 10, 110, 20), (100, 20, 110, 30), (100, 170, 110, 180), (100, 180, 110, 190), (100, 190, 110, 200), (110, 0, 120, 10), (110, 10, 120, 20), (110, 20, 120, 30), (110, 170, 120, 180), (110, 180, 120, 190), (110, 190, 120, 200), (120, 0, 130, 10), (120, 10, 130, 20), (120, 20, 130, 30), (120, 170, 130, 180), (120, 180, 130, 190), (120, 190, 130, 200), (130, 0, 140, 10), (130, 10, 140, 20), (130, 20, 140, 30), (130, 30, 140, 40), (130, 160, 140, 170), (130, 170, 140, 180), (130, 180, 140, 190), (130, 190, 140, 200), (140, 0, 150, 10), (140, 10, 150, 20), (140, 20, 150, 30), (140, 30, 150, 40), (140, 40, 150, 50), (140, 50, 150, 60), (140, 140, 150, 150), (140, 150, 150, 160), (140, 160, 150, 170), (140, 170, 150, 180), (140, 180, 150, 190), (140, 190, 150, 200), (150, 0, 160, 10), (150, 10, 160, 20), (150, 20, 160, 30), (150, 30, 160, 40), (150, 40, 160, 50), (150, 50, 160, 60), (150, 140, 160, 150), (150, 150, 160, 160), (150, 160, 160, 170), (150, 170, 160, 180), (150, 180, 160, 190), (150, 190, 160, 200), (160, 0, 170, 10), (160, 10, 170, 20), (160, 20, 170, 30), (160, 30, 170, 40), (160, 40, 170, 50), (160, 50, 170, 60), (160, 60, 170, 70), (160, 130, 170, 140), (160, 140, 170, 150), (160, 150, 170, 160), (160, 160, 170, 170), (160, 170, 170, 180), (160, 180, 170, 190), (160, 190, 170, 200), (170, 0, 180, 10), (170, 10, 180, 20), (170, 20, 180, 30), (170, 30, 180, 40), (170, 40, 180, 50), (170, 50, 180, 60), (170, 60, 180, 70), (170, 70, 180, 80), (170, 80, 180, 90), (170, 90, 180, 100), (170, 100, 180, 110), (170, 110, 180, 120), (170, 120, 180, 130), (170, 130, 180, 140), (170, 140, 180, 150), (170, 150, 180, 160), (170, 160, 180, 170), (170, 170, 180, 180), (170, 180, 180, 190), (170, 190, 180, 200), (180, 0, 190, 10), (180, 10, 190, 20), (180, 20, 190, 30), (180, 30, 190, 40), (180, 40, 190, 50), (180, 50, 190, 60), (180, 60, 190, 70), (180, 70, 190, 80), (180, 80, 190, 90), (180, 90, 190, 100), (180, 100, 190, 110), (180, 110, 190, 120), (180, 120, 190, 130), (180, 130, 190, 140), (180, 140, 190, 150), (180, 150, 190, 160), (180, 160, 190, 170), (180, 170, 190, 180), (180, 180, 190, 190), (180, 190, 190, 200), (190, 0, 200, 10), (190, 10, 200, 20), (190, 20, 200, 30), (190, 30, 200, 40), (190, 40, 200, 50), (190, 50, 200, 60), (190, 60, 200, 70), (190, 70, 200, 80), (190, 80, 200, 90), (190, 90, 200, 100), (190, 100, 200, 110), (190, 110, 200, 120), (190, 120, 200, 130), (190, 130, 200, 140), (190, 140, 200, 150), (190, 150, 200, 160), (190, 160, 200, 170), (190, 170, 200, 180), (190, 180, 200, 190), (190, 190, 200, 200)], 65: [(30, 70, 40, 80)], 27: [(30, 80, 40, 90)], 11: [(30, 90, 40, 100)], 13: [(30, 100, 40, 110)], 30: [(30, 110, 40, 120), (60, 110, 70, 120), (60, 120, 70, 130), (100, 130, 110, 140), (110, 130, 120, 140), (120, 90, 130, 100), (120, 130, 130, 140), (130, 70, 140, 80), (130, 80, 140, 90)], 71: [(30, 120, 40, 130)], 76: [(40, 60, 50, 70), (130, 40, 140, 50), (160, 120, 170, 130)], 0: [(40, 70, 50, 80), (40, 80, 50, 90), (40, 90, 50, 100), (40, 100, 50, 110), (40, 110, 50, 120), (50, 70, 60, 80), (50, 80, 60, 90), (50, 90, 60, 100), (50, 100, 60, 110), (50, 110, 60, 120), (50, 120, 60, 130), (60, 70, 70, 80), (60, 80, 70, 90), (60, 90, 70, 100), (70, 40, 80, 50), (70, 50, 80, 60), (70, 70, 80, 80), (70, 80, 80, 90), (70, 110, 80, 120), (70, 120, 80, 130), (70, 130, 80, 140), (70, 140, 80, 150), (70, 150, 80, 160), (80, 40, 90, 50), (80, 50, 90, 60), (80, 70, 90, 80), (80, 80, 90, 90), (80, 110, 90, 120), (80, 120, 90, 130), (80, 130, 90, 140), (80, 140, 90, 150), (80, 150, 90, 160), (90, 40, 100, 50), (90, 50, 100, 60), (90, 70, 100, 80), (90, 80, 100, 90), (90, 110, 100, 120), (90, 120, 100, 130), (90, 130, 100, 140), (90, 140, 100, 150), (90, 150, 100, 160), (100, 40, 110, 50), (100, 50, 110, 60), (100, 60, 110, 70), (100, 70, 110, 80), (100, 80, 110, 90), (100, 110, 110, 120), (100, 120, 110, 130), (100, 140, 110, 150), (100, 150, 110, 160), (110, 40, 120, 50), (110, 50, 120, 60), (110, 60, 120, 70), (110, 70, 120, 80), (110, 80, 120, 90), (110, 110, 120, 120), (110, 120, 120, 130), (110, 140, 120, 150), (110, 150, 120, 160), (120, 40, 130, 50), (120, 50, 130, 60), (120, 60, 130, 70), (120, 70, 130, 80), (120, 80, 130, 90), (120, 100, 130, 110), (120, 110, 130, 120), (120, 120, 130, 130), (120, 140, 130, 150), (130, 100, 140, 110), (130, 110, 140, 120), (130, 120, 140, 130), (140, 70, 150, 80), (140, 80, 150, 90), (140, 90, 150, 100), (140, 100, 150, 110), (140, 110, 150, 120), (140, 120, 150, 130), (150, 70, 160, 80), (150, 80, 160, 90), (150, 90, 160, 100), (150, 100, 160, 110), (150, 110, 160, 120)], 1: [(40, 120, 50, 130), (120, 150, 130, 160), (150, 120, 160, 130)], 83: [(40, 130, 50, 140)], 60: [(50, 60, 60, 70), (60, 50, 70, 60), (60, 140, 70, 150), (140, 60, 150, 70)], 70: [(50, 130, 60, 140), (130, 50, 140, 60), (130, 140, 140, 150), (140, 130, 150, 140)], 97: [(60, 30, 70, 40)], 66: [(60, 40, 70, 50)], 52: [(60, 60, 70, 70)], 16: [(60, 100, 70, 110), (80, 30, 90, 40)], 51: [(60, 130, 70, 140)], 78: [(60, 150, 70, 160)], 43: [(70, 30, 80, 40)], 40: [(70, 60, 80, 70), (80, 60, 90, 70)], 6: [(70, 90, 80, 100)], 26: [(70, 100, 80, 110)], 72: [(70, 160, 80, 170)], 20: [(80, 90, 90, 100), (90, 90, 100, 100), (100, 90, 110, 100), (110, 90, 120, 100)], 10: [(80, 100, 90, 110), (90, 30, 100, 40), (90, 100, 100, 110), (100, 30, 110, 40), (100, 100, 110, 110)], 32: [(80, 160, 90, 170)], 36: [(90, 60, 100, 70)], 14: [(90, 160, 100, 170), (160, 90, 170, 100), (160, 100, 170, 110)], 15: [(100, 160, 110, 170)], 17: [(110, 30, 120, 40)], 9: [(110, 100, 120, 110), (130, 90, 140, 100)], 33: [(110, 160, 120, 170), (160, 110, 170, 120)], 54: [(120, 30, 130, 40), (130, 60, 140, 70)], 73: [(120, 160, 130, 170)], 58: [(130, 130, 140, 140)], 81: [(130, 150, 140, 160), (150, 130, 160, 140)], 69: [(150, 60, 160, 70)], 64: [(160, 70, 170, 80)], 31: [(160, 80, 170, 90)]}

######################################################

print(groupby_even_odd(

    seq=[1, 2, 3, 45, 56, 6, 32, 12], continue_on_exceptions=True, withindex=False

))

# output: {'odd': [1, 3, 45], 'even': [2, 56, 6, 32, 12]}

######################################################

print(

    groupby_files_folder_link(

        seq=[

            os.path.join(r"F:\gitrep\screenshots", x)

            for x in os.listdir(r"F:\gitrep\screenshots")

        ],

        continue_on_exceptions=True,

        withindex=False,

        withvalue=True,

    )

)

# output: {'folder': ['F:\\gitrep\\screenshots\\.git', 'F:\\gitrep\\screenshots\\color', 'F:\\gitrep\\screenshots\\debugdf', 'F:\\gitrep\\screenshots\\enumeratefiles', 'F:\\gitrep\\screenshots\\sortfiles'], 'file': ['F:\\gitrep\\screenshots\\.gitignore', 'F:\\gitrep\\screenshots\\144.png', 'F:\\gitrep\\screenshots\\146.png', 'F:\\gitrep\\screenshots\\2022-12-27 03_40_27-.png', 'F:\\gitrep\\screenshots\\2022-12-27 03_49_27-.png', 'F:\\gitrep\\screenshots\\2022-12-27 04_01_57-.png', 'F:\\gitrep\\screenshots\\2022-12-27 04_02_09-.png', 'F:\\gitrep\\screenshots\\2023-01-01 09_48_27-single_elements.png', 'F:\\gitrep\\screenshots\\add_methods.png', 'F:\\gitrep\\screenshots\\allcolors.png', 'F:\\gitrep\\screenshots\\asciiart.png', 'F:\\gitrep\\screenshots\\bluestacksauto.png', 'F:\\gitrep\\screenshots\\buttonsearch.png', 'F:\\gitrep\\screenshots\\collage.png', 'F:\\gitrep\\screenshots\\colorfind1.png', 'F:\\gitrep\\screenshots\\colorfind1xxx.png', 'F:\\gitrep\\screenshots\\colorfind2.png', 'F:\\gitrep\\screenshots\\colorfind3.png', 'F:\\gitrep\\screenshots\\colorfind4.png', 'F:\\gitrep\\screenshots\\cv2_putTrueTypeText_000000.png', 'F:\\gitrep\\screenshots\\cv2_putTrueTypeText_000001.png', 'F:\\gitrep\\screenshots\\cv2_putTrueTypeText_000002.png', 'F:\\gitrep\\screenshots\\cv2_putTrueTypeText_000003.png', 'F:\\gitrep\\screenshots\\cv2_putTrueTypeText_000004.png', 'F:\\gitrep\\screenshots\\cv2_putTrueTypeText_000005.png', 'F:\\gitrep\\screenshots\\cv2_putTrueTypeText_000006.png', 'F:\\gitrep\\screenshots\\cv2_putTrueTypeText_000007.png', 'F:\\gitrep\\screenshots\\cv2_putTrueTypeText_000008.png', 'F:\\gitrep\\screenshots\\cv2_putTrueTypeText_000009.png', 'F:\\gitrep\\screenshots\\cv2_putTrueTypeText_000010.png', 'F:\\gitrep\\screenshots\\cv2_putTrueTypeText_000011.png', 'F:\\gitrep\\screenshots\\cv2_putTrueTypeText_000012.png', 'F:\\gitrep\\screenshots\\cv2_putTrueTypeText_000013.png', 'F:\\gitrep\\screenshots\\cv2_putTrueTypeText_000014.png', 'F:\\gitrep\\screenshots\\cv2_putTrueTypeText_000015.png', 'F:\\gitrep\\screenshots\\cv2_putTrueTypeText_000017.png', 'F:\\gitrep\\screenshots\\dfresults.png', 'F:\\gitrep\\screenshots\\df_act01.png', 'F:\\gitrep\\screenshots\\df_act01_0.png', 'F:\\gitrep\\screenshots\\df_act02.png', 'F:\\gitrep\\screenshots\\df_act02_0.png', 'F:\\gitrep\\screenshots\\df_screen01.png', 'F:\\gitrep\\screenshots\\df_screen02.png', 'F:\\gitrep\\screenshots\\df_style.css', 'F:\\gitrep\\screenshots\\diff.png', 'F:\\gitrep\\screenshots\\findshapes_1.png', 'F:\\gitrep\\screenshots\\findshapes_2.png', 'F:\\gitrep\\screenshots\\findsquare.png', 'F:\\gitrep\\screenshots\\fromjsonorg.html', 'F:\\gitrep\\screenshots\\fromjsonorg.png', 'F:\\gitrep\\screenshots\\from_nested_dict.html', 'F:\\gitrep\\screenshots\\from_nested_dict.png', 'F:\\gitrep\\screenshots\\generateimgs.png', 'F:\\gitrep\\screenshots\\horizontal.png', 'F:\\gitrep\\screenshots\\imagediffsquare.png', 'F:\\gitrep\\screenshots\\jsonstring.html', 'F:\\gitrep\\screenshots\\jsonstring.png', 'F:\\gitrep\\screenshots\\json_from_file.html', 'F:\\gitrep\\screenshots\\json_from_file.png', 'F:\\gitrep\\screenshots\\json_from_file_sp.png', 'F:\\gitrep\\screenshots\\json_url.html', 'F:\\gitrep\\screenshots\\json_url.png', 'F:\\gitrep\\screenshots\\LICENSE', 'F:\\gitrep\\screenshots\\lines.png', 'F:\\gitrep\\screenshots\\merg1.png', 'F:\\gitrep\\screenshots\\merg2.png', 'F:\\gitrep\\screenshots\\merg3.png', 'F:\\gitrep\\screenshots\\merg4.png', 'F:\\gitrep\\screenshots\\merg5.png', 'F:\\gitrep\\screenshots\\merg6.png', 'F:\\gitrep\\screenshots\\merg7.png', 'F:\\gitrep\\screenshots\\myhtml.html', 'F:\\gitrep\\screenshots\\noformat.png', 'F:\\gitrep\\screenshots\\norm.png', 'F:\\gitrep\\screenshots\\pandasconsoleplott.png', 'F:\\gitrep\\screenshots\\pandsnesteddicthtml.png', 'F:\\gitrep\\screenshots\\papag_00000000.png', 'F:\\gitrep\\screenshots\\papag_00000001.png', 'F:\\gitrep\\screenshots\\papag_00000002.png', 'F:\\gitrep\\screenshots\\papag_00000003.png', 'F:\\gitrep\\screenshots\\papag_00000004.png', 'F:\\gitrep\\screenshots\\papag_00000005.png', 'F:\\gitrep\\screenshots\\papag_00000006.png', 'F:\\gitrep\\screenshots\\papag_00000007.png', 'F:\\gitrep\\screenshots\\papag_00000008.png', 'F:\\gitrep\\screenshots\\papag_00000009.png', 'F:\\gitrep\\screenshots\\pic1.png', 'F:\\gitrep\\screenshots\\pic2.png', 'F:\\gitrep\\screenshots\\pic3.png', 'F:\\gitrep\\screenshots\\pic4.png', 'F:\\gitrep\\screenshots\\pic5.png', 'F:\\gitrep\\screenshots\\PROXY.png', 'F:\\gitrep\\screenshots\\randomscreenshots.png', 'F:\\gitrep\\screenshots\\rect1.png', 'F:\\gitrep\\screenshots\\rect2.png', 'F:\\gitrep\\screenshots\\resultsscreenshots.png', 'F:\\gitrep\\screenshots\\rotate1.png', 'F:\\gitrep\\screenshots\\rotate2.png', 'F:\\gitrep\\screenshots\\screencap1.png', 'F:\\gitrep\\screenshots\\screencap2.png', 'F:\\gitrep\\screenshots\\screencap3.png', 'F:\\gitrep\\screenshots\\screencap4.png', 'F:\\gitrep\\screenshots\\screenshotpandasseries.png', 'F:\\gitrep\\screenshots\\screenshotpandastable.png', 'F:\\gitrep\\screenshots\\seleniumkeys.png', 'F:\\gitrep\\screenshots\\sendevent_key.png', 'F:\\gitrep\\screenshots\\sendevent_key_video.png', 'F:\\gitrep\\screenshots\\sift.png', 'F:\\gitrep\\screenshots\\splitted0.png', 'F:\\gitrep\\screenshots\\splitted1.jpeg', 'F:\\gitrep\\screenshots\\splitted1.png', 'F:\\gitrep\\screenshots\\templatematching1.png', 'F:\\gitrep\\screenshots\\templatematching2.png', 'F:\\gitrep\\screenshots\\templatematching3.png', 'F:\\gitrep\\screenshots\\templatematching4.png', 'F:\\gitrep\\screenshots\\templatematching5.png', 'F:\\gitrep\\screenshots\\templatematching6.png', 'F:\\gitrep\\screenshots\\templatematching7.png', 'F:\\gitrep\\screenshots\\tensorflowscreen.png', 'F:\\gitrep\\screenshots\\tesseractscreen.mp4', 'F:\\gitrep\\screenshots\\tesseractscreen.png', 'F:\\gitrep\\screenshots\\testwholescreenshot.png', 'F:\\gitrep\\screenshots\\timemea.png', 'F:\\gitrep\\screenshots\\vc01.png', 'F:\\gitrep\\screenshots\\vc01_0.png', 'F:\\gitrep\\screenshots\\vertical.png', 'F:\\gitrep\\screenshots\\zoompics_0000001.png', 'F:\\gitrep\\screenshots\\zoompics_0000002.png', 'F:\\gitrep\\screenshots\\zoompics_0000003.png', 'F:\\gitrep\\screenshots\\zoompics_0000004.png', 'F:\\gitrep\\screenshots\\zoompics_0000005.png', 'F:\\gitrep\\screenshots\\zoompics_0000006.png', 'F:\\gitrep\\screenshots\\zoompics_0000007.png', 'F:\\gitrep\\screenshots\\zoompics_0000008.png']}

######################################################

import pandas as pd

import math

import numpy as np

print(groupby_sys_size(seq=[pd.NA, np.nan, None, math.nan, 3,54,3,(22,34,412), {323,31}, [3312,3]], continue_on_exceptions=True, withindex=False))



# output: {48: [<NA>], 24: [nan, nan], 16: [None], 28: [3, 54, 3], 64: [(22, 34, 412)], 216: [{323, 31}], 72: [[3312, 3]]}

######################################################

print(groupby_first_item(

    seq=[[1,2,34,], (1,32,4), (2,3,4,54), [2,3,3]], continue_on_exceptions=True, withindex=False

))

# output: {1: [[1, 2, 34], (1, 32, 4)], 2: [(2, 3, 4, 54), [2, 3, 3]]}

######################################################

print(groupby_words_in_texts(

    textlist=["autobahn", "computerproblem", "kind", "opa", "kind opa"],

    wordlist=["kind", "opa"],

    case_sen=False,

    continue_on_exceptions=True,

    withindex=False,

    boundary_right=True,

    boundary_left=True,

))

# output: {(): ['autobahn', 'computerproblem'], ('kind',): ['kind'], ('opa',): ['opa'], ('kind', 'opa'): ['kind opa']}

######################################################

print(groupby_sum(

    seq=[[1, 2, 2], [5], [2, 3], [4, 4, 4], [12, 0], [6, 6], [1, 2]],

    continue_on_exceptions=True,

    withindex=False,

))

# output: {5: [[1, 2, 2], [5], [2, 3]], 12: [[4, 4, 4], [12, 0], [6, 6]], 3: [[1, 2]]}

######################################################

print(groupby_valid_url(

    seq=["https://www.google.com", "google.com/", 'bababa', 'http://baba.de'],

    continue_on_exceptions=True,

    withindex=False,

    withvalue=True,

))

# output: {'valid': ['https://www.google.com', 'http://baba.de'], 'not_valid': ['google.com/', 'bababa']}

######################################################

print(groupby_literal_eval_type(

    seq=['11', 'bb', '"bb"'], continue_on_exceptions=True, withindex=False, withvalue=True

))

# output: {<class 'int'>: ['11'], 'EXCEPTION: malformed node or string: <ast.Name object at 0x0000000013A54340>': ['bb'], <class 'str'>: ['"bb"']}

######################################################

rint(groupby_decoding_result(bytes_=b'\\U0001D11E',mode='strict',

     continue_on_exceptions=True, withindex=False, withvalue=True

))

# output:  {'\\U0001D11E': ['ascii',

#                 'big5',

#                 'big5hkscs',

#                 'charmap',

# 				 ......

#                 'palmos',

#                 'ptcp154',

#                 'shift_jis',

#                 'tis_620',

#                 'utf_7',

#                 'utf_8',

#                 'utf_8_sig'],

# '¥U0001D11E': ['shift_jisx0213', 'shift_jis_2004'],

# '啜〰\u3130ㅄ䔱': ['utf_16', 'utf_16_le'],

# '展〰〱䐱ㅅ': ['utf_16_be'],

# '𝄞': ['raw_unicode_escape', 'unicode_escape']}

######################################################

print(groupby_percentage(

    seq=10*[1,2,34,4,2,3,54,6,6,4,3,2,21,45,56], percent_true=63.7, continue_on_exceptions=True, withindex=False, withvalue=True

))

# output: {False: [1, 2, 4, 3, 2, 34, 4, 2, 3, 4, 56, 4, 2, 45, 2, 2, 3, 54, 2, 21, 1, 4, 6, 3, 21, 34, 2, 54, 3, 21, 45, 1, 2, 4, 54, 6, 4, 56, 1, 4, 56, 1, 2, 4, 54, 3, 1, 54, 4, 3, 21], True: [2, 34, 4, 3, 54, 6, 6, 21, 45, 56, 1, 2, 54, 6, 6, 3, 2, 21, 45, 1, 2, 34, 2, 3, 54, 6, 6, 4, 3, 21, 56, 1, 34, 4, 6, 6, 4, 3, 45, 56, 2, 34, 2, 3, 54, 6, 4, 2, 45, 56, 1, 2, 4, 3, 6, 6, 4, 2, 56, 34, 2, 3, 6, 3, 2, 21, 45, 2, 34, 2, 3, 54, 6, 6, 4, 3, 2, 21, 45, 34, 2, 3, 6, 6, 4, 2, 21, 45, 56, 2, 34, 4, 2, 3, 6, 6, 2, 45, 56]}

######################################################

print(groupby_almost_equal(

    seq=[11,200,34,4,52,63,54,65,67,48,3,2,21,55,56,59,61,60], value=60, equallimit=3, continue_on_exceptions=True, withindex=False, withvalue=True

))

# output: {False: [11, 200, 34, 4, 52, 54, 65, 67, 48, 3, 2, 21, 55, 56], True: [63, 59, 61, 60]}

######################################################

coordlist = 2 * [(1, 2), (34, 4), (2, 3), (61, 60)]

print(groupby_coords_almost_equal(seq=coordlist, x_coord=4, y_coord=3, limit_x=5, limit_y=1,

                                  continue_on_exceptions=True, withindex=False, withvalue=True))



# output: {(True, True): [(1, 2), (2, 3), (1, 2), (2, 3)], (False, True): [(34, 4), (34, 4)], (False, False): [(61, 60), (61, 60)]}

######################################################

coordlist = [(745, 519),

 (747, 522),

 (747, 517),

 (747, 517),

 (750, 522),

 (756, 449),

 (757, 461),

 (757, 461),

 (757, 438),

 (830, 144),

 (759, 435),

 (759, 435),

 (761, 468),

 (761, 468),

 (764, 521),

 (1079, 199),

 (770, 474),

 (770, 425),

 (773, 516),

 (776, 515),

 (776, 515),

 (778, 520),

 (779, 519),

 (780, 420),

 (780, 420),

 (782, 478),

 (782, 478),

 (1083, 151),

 (1083, 151),

 (1083, 151),

 (1083, 151),

 (784, 478),

 (759, 435),

 (784, 478),

 (819, 137),

 (819, 137),

 (819, 137),

 (797, 524),

 (825, 125),

 (826, 149),

 (800, 446),

 (800, 446),

 (801, 517),

 (801, 517),

 (802, 520),

 (802, 520),

 (804, 519),

 (804, 519),

 (808, 431),

 (808, 431),

 (809, 464),

 (809, 464),

 (812, 438),

 (813, 449)]



xx=(group_coordinates_by_distance(coordlist, limit_x=10, limit_y=10, continue_on_exceptions=True))

for x in xx:

    print(x)



# output: ((813, 449),)

# ((779, 519), (773, 516), (776, 515), (778, 520), (764, 521))

# ((808, 431), (812, 438))

# ((1083, 151),)

# ((830, 144), (826, 149))

# ((761, 468), (757, 461), (770, 474))

# ((825, 125),)

# ((756, 449),)

# ((745, 519), (747, 517), (750, 522), (747, 522))

# ((780, 420), (770, 425))

# ((784, 478), (782, 478))

# ((804, 519), (802, 520), (797, 524), (801, 517))

# ((757, 438), (759, 435))

# ((819, 137),)

# ((809, 464),)

# ((800, 446),)

# ((1079, 199),)

######################################################

```







### Iter stuff



```python

######################################################

for _ in iter_enumerate_multiple([3, 4], [55, 55]):

    print(_)



# output: 

(0, 3, 55)

(1, 4, 55)

######################################################	

for j in iter__chain([3, 4], [55, 55], [{33:31}, 4,1]):

    print(j)	



# output: 

3

4

55

55

{33: 31}

4

1	

######################################################

people = {1: {"name": "John", "age": "27", "sex": "Male"}, 2: {"name": "Marie", "age": "22", "sex": "Female"},

          3: {"name": "Luna", "age": "24", "sex": "Female"},

          4: {"name": "Peter", "age": "29", "sex": ["Female", "Male"], 1: "xx", "sex2": ("Female", "Male"), }, }

for keys, item in iter_nested_dict(people):

    print(keys, item)



# output: 

(1, 'name') John

(1, 'age') 27

(1, 'sex') Male

(2, 'name') Marie

(2, 'age') 22

(2, 'sex') Female

(3, 'name') Luna

(3, 'age') 24

(3, 'sex') Female

(4, 'name') Peter

(4, 'age') 29

(4, 'sex', 0) Female

(4, 'sex', 1) Male

(4, 1) xx

(4, 'sex2', 0) Female

(4, 'sex2', 1) Male

######################################################

for x in (iter_split_list_into_chunks_fill_rest(n=3, iterable=[1, 2, 3, 4, 4, 2, 21], fillvalue=None)):

    print(x)

	

# output: 	

(1, 2, 3)

(4, 4, 2)

(21, None, None)

######################################################

print(

    list(

        iter_cycle_shortest(

            iter1=[33, 133, 35, 3300],

            iter2=[331, 1133, 434, 44, 555, 22, 767, 446, 66, 2234],

        )

    )

)

# output: 

# [(33, 331), (133, 1133), (35, 434), (3300, 44), (33, 555), (133, 22), (35, 767), (3300, 446), (33, 66), (133, 2234)]



print(

    list(

        iter_cycle_shortest(

            iter1=[331, 1133, 434, 44, 555, 22, 767, 446, 66, 2234],

            iter2=[33, 133, 35, 3300],

        )

    )

)

# output: 

# [(331, 33), (1133, 133), (434, 35), (44, 3300), (555, 33), (22, 133), (767, 35), (446, 3300), (66, 33), (2234, 133)]

######################################################

print(list(iter_reverse_lists_of_list(lis=((323,33,331), (331,552,1)))))

# output: [[331, 33, 323], [1, 552, 331]]

######################################################

print(list(iter_split_by_index("For performance reasons, the value of errors is not checked for validity", [6, 8, 12, 13, 18])))

# output: ['For pe', 'rf', 'orma', 'n', 'ce re', 'asons, the value of errors is not checked for validity']



print(list(iter_split_by_index([32.,3,123,424,4242,4,24,532,54,53254,24,24,24,532,35624,42], [6, 8, 12, 13, 18])))

# output: [[32.0, 3, 123, 424, 4242, 4], [24, 532], [54, 53254, 24, 24], [24], [532, 35624, 42], []]

######################################################

for kl in iter_get_every_nth_element(iterable=[1,2,3,4,4,5,6,3,2.4,4,5,5,4],start=0, step=2):

    print(kl)

# output: 

1

3

4

6

2.4

5

4

######################################################

print(list(iter_find_same_ending_elements(iters=[list((1,2,3,4)), list((1,2,3,4)), list((5,1,2,3,4))])))

# output: [1, 2, 3, 4]

######################################################

print(list(iter_find_same_beginning_elements(iters=[list((1,2,3,4)), list((1,2,3,4)), list((1,2,3,4,5))])))

# output: [1, 2, 3, 4]

######################################################

for x in iter_nested_list_from_item(variable=[244, 244, 2], shape=(2, 3,2)):

    print(x)

# output: [[[244, 244, 2], [244, 244, 2]], [[244, 244, 2], [244, 244, 2]], [[244, 244, 2], [244, 244, 2]]]

#         [[[244, 244, 2], [244, 244, 2]], [[244, 244, 2], [244, 244, 2]], [[244, 244, 2], [244, 244, 2]]]

######################################################

print(list(iter_repeat_items(iterable=[34,4,23], reps=3)))

# output: [34, 34, 34, 4, 4, 4, 23, 23, 23]

######################################################

print(iter_count_occurrences_of_item_in_multiple_iterables(iterables=[['hallo', 'mein', 'Freund', 'ou'],['hallo', 'mein', 'Freund', 'oxu']]))

# output: Counter({'hallo': 2, 'mein': 2, 'Freund': 2, 'ou': 1, 'oxu': 1})

######################################################

print(iter_count_occurrences_of_item_in_multiple_iterables_flatten_everything(iterables=[['hallo', ['mein', 'Freund'], 'ou'],['hallo', ['mein'], 'Freund', 'oxu']]))

# output: Counter({'hallo': 2, 'mein': 2, 'Freund': 2, 'ou': 1, 'oxu': 1})

######################################################

list1 = [(255, 255, 0), (255, 21, 23), (0, 0, 0), (1, 1, 1)]

list2 = ['yellow', 'red', 'black', 'black']

print(list(iter_values_from_list1_based_on_values_of_list2(list1, list2, condition=lambda x: x == 'black')))

# output: [(0, 0, 0), (1, 1, 1)]

######################################################

print(list(iter_windowed(iterable=[1,23,3,2,34], n=2)))

# output: [(1, 23), (23, 3), (3, 2), (2, 34)]

######################################################

for subit in iter_batch('ABCDEFG', 3):

    for x in subit:

        print(x, end=' ')

    print()



# output:	

A B C 

D E F 

G 

######################################################

npar = numpy_all_permutations(iterable=list('abcdefghijklmnop'), len_of_each=6)

# output:

array([['a', 'b', 'c', 'd', 'e', 'f'],

       ['a', 'b', 'c', 'd', 'e', 'g'],

       ['a', 'b', 'c', 'd', 'e', 'h'],

       ...,

       ['p', 'o', 'n', 'm', 'l', 'i'],

       ['p', 'o', 'n', 'm', 'l', 'j'],

       ['p', 'o', 'n', 'm', 'l', 'k']], dtype='<U1')



print(npar.shape)

(5765760, 6)

######################################################

print(numpy_random_array_no_reps_beginning_end(iterable=['hallo','du','wie','er', 'ich', 'es'], block_count=3))

# output:

[['du' 'wie' 'es' 'ich' 'er' 'hallo']

 ['es' 'hallo' 'ich' 'du' 'wie' 'er']

 ['du' 'ich' 'wie' 'er' 'es' 'hallo']]	

######################################################

l1 = [1, 2, 3]

l2 = [4, 5, 6]

l3 = [7, 8, 9]

for l11, l22, l33 in iter_nested_for_loop(l1, l2, l3):

    print(l11, l22, l33)

# output:

1 4 7

1 4 8

1 4 9

1 5 7

1 5 8

1 5 9

1 6 7

1 6 8

1 6 9

2 4 7

2 4 8

2 4 9

2 5 7

2 5 8

2 5 9

2 6 7

2 6 8

2 6 9

3 4 7

3 4 8

3 4 9

3 5 7

3 5 8

3 5 9

3 6 7

3 6 8

3 6 9

######################################################

l1 = [1, 2, 3]

l2 = [4, 5, 6]

l3 = [7, 8, 9]

for ini, l11, l22, l33 in iter_nested_for_loop_enumerate(l1, l2, l3):

    print(ini, l11, l22, l33)





# output:



0 1 4 7

1 1 4 8

2 1 4 9

3 1 5 7

4 1 5 8

5 1 5 9

6 1 6 7

7 1 6 8

8 1 6 9

9 2 4 7

10 2 4 8

11 2 4 9

12 2 5 7

13 2 5 8

14 2 5 9

15 2 6 7

16 2 6 8

17 2 6 9

18 3 4 7

19 3 4 8

20 3 4 9

21 3 5 7

22 3 5 8

23 3 5 9

24 3 6 7

25 3 6 8

26 3 6 9

######################################################

for i in iter_chain_flatten([332313,5434,2342], {3232,342},312, 331):

    print(i)



# output:	

332313

5434

2342

3232

342

312

331



######################################################

for ini,cir in enumerate(iter_spiral(radius=10,eccentricity = 1.5,step = 0.1,t = 0)):

    print(cir)

    if ini==15:

        break



# output:

(1.4925062479170388, 0.09983341664682815)

(2.940199733523725, 0.39733866159012243)

(4.299014201065228, 0.8865606199840189)

(5.526365964017311, 1.557673369234602)

(6.581869214177796, 2.397127693021015)

(7.428020534187105, 3.3878548403702125)

(8.030842966487128, 4.509523810663837)

(8.360480512165985, 5.7388487271961806)

(8.39173457165397, 7.04994218664735)

(8.104534588022096, 8.414709848078962)

(7.484336003522027, 9.803280960675787)

(6.522439580580125, 11.184469031606715)

(5.2162271581794535, 12.526256410423509)

(3.5693100009050576, 13.796296219838446)

(1.5915870375233105, 14.962424799060818)

(-0.700788535230937, 15.993177648664085)		



######################################################

vara= ['key1','x', 'key2',['one', 'two', 'three']]



# normal python version

for k in vara:

    if isinstance(k,list):

        for li in k:

            print(k, li)

    else:

        print(k)



# output:	

key1

x

key2

['one', 'two', 'three'] one

['one', 'two', 'three'] two

['one', 'two', 'three'] three





# same thing, but much shorter:

for k in iter_nested(iterable=vara):

    print(k)



# output:		

['key1']

['x']

['key2']

[['one', 'two', 'three'], 'one']

[['one', 'two', 'three'], 'two']

[['one', 'two', 'three'], 'three']	



######################################################

# same as iter_nested, but with path to each value

for k in iter_nested_with_path(iterable=vara):

    print(k)



# output:	

[((0,), 'key1')]

[((1,), 'x')]

[((2,), 'key2')]

[((3,), ['one', 'two', 'three']), ((3, 0), 'one')]

[((3,), ['one', 'two', 'three']), ((3, 1), 'two')]

[((3,), ['one', 'two', 'three']), ((3, 2), 'three')]	

######################################################

print(list(iter_add_one_item_each_iteration(iterable=vara)))

# output:	[['key1'], ['key1', 'x'], ['key1', 'x', 'key2'], ['key1', 'x', 'key2', ['one', 'two', 'three']]]

######################################################

print(list(iter_add_one_item_each_iteration_reverse(iterable=vara)))

# output:	[[['one', 'two', 'three']], ['key2', ['one', 'two', 'three']], ['x', 'key2', ['one', 'two', 'three']], ['key1', 'x', 'key2', ['one', 'two', 'three']]]

######################################################

from ansi.colour.rgb import rgb8, rgb16, rgb256

from ansi.colour import fg, bg, fx

text='bababa'

for colour in iter_rainbow_colors(num_colors=10):

    print(colour)

    print("".join(list(map(str, (

            fx.bold, bg.brightwhite, fg.brightwhite, rgb256(colour[0], colour[1], colour[2]), text, bg.brightwhite,

            fg.brightwhite, fx.bold, fx.reset,), ))))

# output:

(250, 54, 54)

bababa

(247, 170, 54)

bababa

(202, 247, 23)

bababa

(79, 254, 35)

bababa

(49, 252, 130)

bababa

(27, 248, 248)

bababa

(33, 120, 250)

bababa

(88, 48, 249)

bababa

(207, 25, 252)

bababa

(248, 42, 166)

bababa

######################################################

print(list(iter_reshape({1: 22, 5: list(range(12))}, [2, [3], {2}, (1, (3,), 2)])))

# output: [[22, 0, [1, 2, 3], {4, 5}, (6, (7, 8, 9), 10, 11)]]

######################################################

for _ in iter_rotate_left(iterable=[1, 2, 3, 4, 5, 6, 3, 2], n=10, onlyfinal=False ):

    print(_)

[2, 3, 4, 5, 6, 3, 2, 1]

[3, 4, 5, 6, 3, 2, 1, 2]

[4, 5, 6, 3, 2, 1, 2, 3]

[5, 6, 3, 2, 1, 2, 3, 4]

[6, 3, 2, 1, 2, 3, 4, 5]

[3, 2, 1, 2, 3, 4, 5, 6]

[2, 1, 2, 3, 4, 5, 6, 3]

[1, 2, 3, 4, 5, 6, 3, 2]

[2, 3, 4, 5, 6, 3, 2, 1]

[3, 4, 5, 6, 3, 2, 1, 2]

######################################################

for _ in iter_rotate_right(iterable=[1, 2, 3, 4, 5, 6, 3, 2], n=10, onlyfinal=False ):

    print(_)

[2, 1, 2, 3, 4, 5, 6, 3]

[3, 2, 1, 2, 3, 4, 5, 6]

[6, 3, 2, 1, 2, 3, 4, 5]

[5, 6, 3, 2, 1, 2, 3, 4]

[4, 5, 6, 3, 2, 1, 2, 3]

[3, 4, 5, 6, 3, 2, 1, 2]

[2, 3, 4, 5, 6, 3, 2, 1]

[1, 2, 3, 4, 5, 6, 3, 2]

[2, 1, 2, 3, 4, 5, 6, 3]

[3, 2, 1, 2, 3, 4, 5, 6]

######################################################

for _ in iter_rotate_left(iterable=[1, 2, 3, 4, 5, 6, 3, 2], n=2, onlyfinal=True ):

    print(_)

[3, 4, 5, 6, 3, 2, 1, 2]    

######################################################

for _ in iter_rotate_right(iterable=[1, 2, 3, 4, 5, 6, 3, 2], n=2, onlyfinal=True):

    print(_)

[3, 2, 1, 2, 3, 4, 5, 6]    

######################################################

from string import ascii_letters

print(iter_number_of_combinations(it=ascii_letters, k=10))

15820024220

######################################################		

for k in iter_call_function_over_and_over_with_new_value(f=lambda x: x * 2, x=1):

    print(k)

    if k > 10000.0:

        break



# output:

1

2

4

8

16

32

64

128

256

512

1024

2048

4096

8192

16384





for k in iter_call_function_over_and_over_with_new_value(f=lambda x: x / 2, x=1):

    print(k)

    if k < 0.001:

        break



# output:

1

0.5

0.25

0.125

0.0625

0.03125

0.015625

0.0078125

0.00390625

0.001953125

0.0009765625

######################################################

for x in iter_stop_when_next_item_is_duplicate(

    it=[

        1,

        2,

        3,

        4,

        5,

        6,

        76,

        77,

        77,

        12,

    ]

):

    print(x)

    

# output:

1

2

3

4

5

6

76

77    

######################################################    

iterable = [

    (233, 233, 1123, [42, 11, 33, 221, 13]),

    (122, 122, 12312),

    (2121, 212),

    (434, 123, 4243, 32),

    (434, 123, 42423, 3322),

]

for list1, list2 in iter_nested_one_ahead(iterable):

    areequal = list1[-1] == list2[-1]

    if areequal:

        print(list1)

        print(list2)



# output:

[(233, 233, 1123, [42, 11, 33, 221, 13]), 233]

[(233, 233, 1123, [42, 11, 33, 221, 13]), 233]

[(122, 122, 12312), 122]

[(122, 122, 12312), 122]

######################################################    

iterable = [

    (233, 233, 1123, [42, 11, 33, 221, 13]),

    (122, 122, 12312),

    (2121, 212),

    (434, 123, 4243, 32),

    (434, 123, 42423, 3322),

]

for ini, p in enumerate(iter_random_values_from_iter_endless(iterable=iterable)):

    if ini == 10:

        break

    print(p)   

# output:

4243

123

1123

3322

42

434

122

32

233

212    

```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/hansalemaos/group_and_iter_everything",
    "name": "group-and-iter-everything",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "itertools,groupby",
    "author": "Johannes Fischer",
    "author_email": "<aulasparticularesdealemaosp@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/75/d6/f8b974489dd288bf14a252dfa5960aec7da2d5c472d536d4e10d0805529e/group_and_iter_everything-0.18.tar.gz",
    "platform": null,
    "description": "\n# Many useful groupby / itertools functions \n\n\n\n```python\n\npip install group-and-iter-everything\n\n```\n\n### update 2023-02-08 \n\n```python\n\nfrom group_and_iter_everything import *\n\n\n\n# sort dict keys\n\nprint(dict(iter_sorted_dict_keys(di={1: 2, 11: 2, 2: 2})))\n\n# output: {1: 2, 2: 2, 11: 2}\n\n###########################################################\n\n# normalize list of lists (same length)\n\nl = [[1, 2, 3], [4, 5], [1]]\n\nprint(list(iter_normalized_list_of_lists(l, fillv=None)))\n\n# output: [[1, 2, 3], [4, 5, None], [1, None, None]]\n\n###########################################################\n\n# transpose list (very useful for coordinates [x,y]])\n\nl = [(1, 2), (3, 4), (4, 5)]\n\nprint(list(iter_transposed_list_of_lists(l)))\n\n\n\nl = [[1, 3, 4], [2, 4, 5]]\n\nprint(list(iter_transposed_list_of_lists(l)))\n\n\n\n# output:\n\n# [[1, 3, 4], [2, 4, 5]]\n\n# [[1, 2], [3, 4], [4, 5]]\n\n###########################################################\n\n# Drop duplicates in nested lists\n\nl2 = [[1, 2], [1, 2], 7, [3, 8], [3, 8]]\n\nprint(list(iter_droped_nested_duplicates(l2)))\n\n# output: [[1, 2], 7, [3, 8]]\n\n###########################################################\n\n# Sort dict by value\n\ndi1 = {1: \"bu\", 11: 2.0, 2: \"anna\"}\n\ndi2 = {1: \"bu\", 11: \"bax\", 2: \"anna\"}\n\nprint(list(iter_sorted_dict_keys_values(di1)))\n\nprint(list(iter_sorted_dict_keys_values(di2)))\n\n\n\n# output:\n\n# [(11, 2.0), (2, 'anna'), (1, 'bu')]\n\n# [(2, 'anna'), (11, 'bax'), (1, 'bu')]\n\n###########################################################\n\n# Group a text by Unicode names\n\ntext = \"\"\"Unidecode is not a replacement for fully supporting Unicode for strings in your program. There are a number of caveats that come with its use, especially when its output is directly visible to users. Please read the rest of this README before using Unidecode in your project.\n\nIn most of examples listed above you could represent Unicode characters as ??? or \\15BA\\15A0\\1610, to mention two extreme cases. But that\u2019s nearly useless to someone who actually wants to read what the text says.\"\"\"\n\ntu = groupby_unicode_name(\n\n    text, continue_on_exceptions=True, withindex=False, withvalue=True\n\n)\n\nprint(tu)\n\n# output:\n\n# ....\n\n# 'LATIN SMALL LETTER B': ['b', 'b', 'b', 'b'],\n\n# 'LATIN SMALL LETTER V': ['v', 'v', 'v'],\n\n# 'LATIN SMALL LETTER W': ['w', 'w', 'w', 'w', 'w', 'w'],\n\n# 'COMMA': [',', ','],\n\n# 'LATIN CAPITAL LETTER P': ['P'],\n\n# 'LATIN CAPITAL LETTER R': ['R'],\n\n# ....\n\n###########################################################\n\n# Call different functions in a thread, and get the result as a dict.\n\nimport requests\n\n\n\ndef testx(\n\n    testnumber, *args, **kwargs\n\n):  # a threaded function must have *args, **kwargs and can't have the keyword argument _starttime.\n\n    # If your function doesn't have *args and **kwargs, add it.\n\n\n\n    print(f\"start {testnumber}\")\n\n    return random.randrange(1, 30)\n\n\n\n\n\ndef reqd(\n\n    u, *args, **kwargs\n\n):  # don't forget: You have to add  *args, **kwargs to the threaded function\n\n    return requests.get(u)\n\n\n\n\n\nurls = [\n\n    \"https://github.com/hansalemaos/a_pandas_ex_regex_enhancements#start-of-content\",\n\n    \"https://github.com/\",\n\n]\n\n# This is how you have to build the list for Threading\n\n# (1, testx, (\"halkl\",), {\"vds\": 3})\n\n# 1 - name of the thread, must be unique!\n\n# testx - the function\n\n# (\"halkl\",) - args (if the function doesn't have args, use ()\n\n# {\"vds\": 3} - kwargs (if the function doesn't have kwargs, use {}\n\nno_fu_args_kwargs = [\n\n    (1, testx, (\"halkl\",), {\"vds\": 3}),\n\n    (2, testx, (\"hxxalkl\",), {\"vxxds\": 3}),\n\n]\n\nalle = len(no_fu_args_kwargs)\n\nfor ini, i in enumerate(urls):  # appending other threads\n\n    no_fu_args_kwargs.append((alle + ini, reqd, (), {\"u\": i}))\n\n\n\nresi = execute_as_thread(\n\n    no_fu_args_kwargs,\n\n    wait_to_complete=True,\n\n    # recommended, if you don't want to wait the function returns None, but you can find your results in group_and_iter_everything.threadingbatch.results, once all threads are done, the key \"done\" will change to True\n\n    return_dict=True,  # Works only when wait_to_complete is True\n\n    threadtlimit=2,  # Limit of threads\n\n    # number of simultaneously executed threads\n\n    timeout=4,\n\n    # call Kthread.kill after n seconds, if your function uses sleep, it is better to use this sleep function: from kthread_sleep import sleep\n\n    sleepafterkill=0.02,  # sleep time after calling Kthread.kill # don't use 0.0\n\n    sleepafterstart=0.02,  # sleep time after starting a thread  # don't use 0.0\n\n    ignore_exceptions=False,  # You can go on when there are Exceptions\n\n    verbose=False,\n\n)\n\n\n\n# output:\n\n# resi\n\n# Out[3]:\n\n# defaultdict(<function threadingbatch.<lambda>()>,\n\n#             {'done': True,\n\n#              '3': defaultdict(<function threadingbatch.<lambda>()>,\n\n#                          {'results': <Response [200]>,\n\n#                           'realstart': 1675824200.253053}),\n\n#              '2': defaultdict(<function threadingbatch.<lambda>()>,\n\n#                          {'results': <Response [200]>,\n\n#                           'realstart': 1675824200.2320704}),\n\n#              '1': defaultdict(<function threadingbatch.<lambda>()>,\n\n#                          {'results': 18, 'realstart': 1675824200.1902106})})\n\n#\n\n#\n\n\n\n# Executing without waiting for the results:\n\n\n\nresi = execute_as_thread(\n\n    no_fu_args_kwargs,\n\n    wait_to_complete=False,\n\n    # you can find the results in group_and_iter_everything.threadingbatch.results, once all threads are done, the key \"done\" will change to True\n\n    return_dict=True,\n\n    threadtlimit=2,\n\n    timeout=4,\n\n    sleepafterkill=0.02,\n\n    sleepafterstart=0.02,\n\n    ignore_exceptions=False,\n\n    verbose=False,\n\n)\n\n\n\n# print(threadingbatch.results)\n\n#\n\n# Not finished yet ('done': False)\n\n#\n\n# defaultdict(<function <lambda> at 0x0000000012A134C0>, {'done': False, '3': defaultdict(<function <lambda> at 0x0000000012A134C0>, {'results': None, 'realstart': None}), '2': defaultdict(<function <lambda> at 0x0000000012A134C0>, {'results': None, 'realstart': None}), '1': defaultdict(<function <lambda> at 0x0000000012A134C0>, {'results': None, 'realstart': None})})\n\n###########################################################\n\n# rjust/ljust a list of strings\n\n\n\ntext = \"\"\"\n\nRead the running tests and linters section of our documentation to learn how to test your code. For cross-browser \n\n\"\"\".split()\n\nlist(\n\n    iter_list_ljust_rjust(\n\n        l=[1, 2] + text,  # can contain any dtype\n\n        ljust=None,  # if None and getmax is True -> the longest str will be used\n\n        ljustchr=\"-\",  # fill with char\n\n        rjust=None,  # if None and getmax is True -> the longest str will be used\n\n        rjustchr=\"-\",  # fill with char\n\n\n\n        getmax=True,\n\n    )\n\n)\n\nlist(\n\n    iter_list_ljust_rjust(\n\n        l=[1, 2] + text, ljust=0, ljustchr=\"-\", rjust=None, rjustchr=\"-\", getmax=True\n\n    )\n\n)\n\nlist(\n\n    iter_list_ljust_rjust(\n\n        l=[1, 2] + text, ljust=None, ljustchr=\"-\", rjust=0, rjustchr=\"-\", getmax=True\n\n    )\n\n)\n\nlist(\n\n    iter_list_ljust_rjust(\n\n        l=[1, 2] + text, ljust=0, ljustchr=\"-\", rjust=12, rjustchr=\"y\", getmax=False\n\n    )\n\n)\n\nlist(\n\n    iter_list_ljust_rjust(\n\n        l=[1, 2] + text, ljust=15, ljustchr=\"x\", rjust=0, rjustchr=\"-\", getmax=False\n\n    )\n\n)\n\n\n\n\n\n# output:\n\n# ['------------1', '------------2', '---------Read', '----------the', '------running', '--------tests', '----------and', '------linters', '------section', '-----------of', '----------our', 'documentation', '-----------to', '--------learn', '----------how', '-----------to', '---------test', '---------your', '--------code.', '----------For', 'cross-browser']\n\n# ['------------1', '------------2', '---------Read', '----------the', '------running', '--------tests', '----------and', '------linters', '------section', '-----------of', '----------our', 'documentation', '-----------to', '--------learn', '----------how', '-----------to', '---------test', '---------your', '--------code.', '----------For', 'cross-browser']\n\n# ['1------------', '2------------', 'Read---------', 'the----------', 'running------', 'tests--------', 'and----------', 'linters------', 'section------', 'of-----------', 'our----------', 'documentation', 'to-----------', 'learn--------', 'how----------', 'to-----------', 'test---------', 'your---------', 'code.--------', 'For----------', 'cross-browser']\n\n# ['yyyyyyyyyyy1', 'yyyyyyyyyyy2', 'yyyyyyyyRead', 'yyyyyyyyythe', 'yyyyyrunning', 'yyyyyyytests', 'yyyyyyyyyand', 'yyyyylinters', 'yyyyysection', 'yyyyyyyyyyof', 'yyyyyyyyyour', 'documentation', 'yyyyyyyyyyto', 'yyyyyyylearn', 'yyyyyyyyyhow', 'yyyyyyyyyyto', 'yyyyyyyytest', 'yyyyyyyyyour', 'yyyyyyycode.', 'yyyyyyyyyFor', 'cross-browser']\n\n# ['1xxxxxxxxxxxxxx', '2xxxxxxxxxxxxxx', 'Readxxxxxxxxxxx', 'thexxxxxxxxxxxx', 'runningxxxxxxxx', 'testsxxxxxxxxxx', 'andxxxxxxxxxxxx', 'lintersxxxxxxxx', 'sectionxxxxxxxx', 'ofxxxxxxxxxxxxx', 'ourxxxxxxxxxxxx', 'documentationxx', 'toxxxxxxxxxxxxx', 'learnxxxxxxxxxx', 'howxxxxxxxxxxxx', 'toxxxxxxxxxxxxx', 'testxxxxxxxxxxx', 'yourxxxxxxxxxxx', 'code.xxxxxxxxxx', 'Forxxxxxxxxxxxx', 'cross-browserxx']\n\n###########################################################\n\n# How to avoid multiple break conditions like in this example\n\ndone = False\n\ncounter = 0\n\nfor i in range(1, 6, 1):  # 1st loop\n\n    print(\"i:\", i)\n\n    for j in range(1, 11, 2):  # 2nd loop\n\n        print(\"   i, j:\", i, j)\n\n        for k in range(1, 21, 4):  # 3rd loop\n\n            print(\"      i,j,k:\", i, j, k)\n\n            if i % 3 == 0 and j % 3 == 0 and k % 3 == 0:\n\n                done = True\n\n                break  # breaking from 3rd loop\n\n        if done:\n\n            break  # breaking from 2nd loop\n\n    if done:\n\n        break  # breaking from 1st loop\n\n    print(counter)\n\n# print(i,j,k)\n\n# 3 3 9\n\n\n\n# Break any nested loop with a condition\n\ndef cond(\n\n    i, j, k\n\n):  # the function which checks every loop if the break condition is True\n\n    return i % 3 == 0 and j % 3 == 0 and k % 3 == 0\n\n\n\n\n\nalli = range(1, 6, 1), range(1, 11, 2), range(1, 21, 4)\n\nfor v in iter_with_breaking_condition(\n\n    *alli,  # pass all iterables\n\n    cond,  # function with the condition\n\n    input_vars={\n\n        \"i\": 0,\n\n        \"j\": 0,\n\n        \"k\": 1,\n\n    },\n\n    # the variables that need to be shared with the condition function, they don't have to exist yet\n\n    output_var=\"outdiv3\",  # the name of the output dict with all variables from input_vars\n\n    delete_old=True,  # input_vars will be deleted\n\n    clean_vars=True,  # input_vars will be deleted after finishing the execution\n\n    print_vars=True,  # verbose\n\n    counter=\"counter\",  # like enumerate\n\n):\n\n    # you can access now all variables that you passed as input_vars as well as counter\n\n    # You have to update them if they are part of the break condition\n\n    it.i, it.j, it.k = v\n\n    print(it.counter)\n\nprint(it.outdiv3)  # you can access the variable in output_var\n\n# output\n\n# print(it.outdiv3)\n\n# {'i': 3, 'j': 3, 'k': 9}\n\n\n\n\n\n\n\n# Another example\n\ndef cond(i, j, k):\n\n    return i % 3 == 0 and j % 3 == 0 and k % 3 == 0\n\n\n\n\n\nalli = [50, 50, 50] * 100, [150, 150, 150] * 100, [250, 250, 250] * 100\n\nfor r, g, b in iter_with_breaking_condition(\n\n    *alli,\n\n    lambda total: total > 10000,\n\n    input_vars={\"total\": 0},\n\n    output_var=\"out\",\n\n    delete_old=True,\n\n    clean_vars=True,\n\n    print_vars=True,\n\n    counter=\"counter\",\n\n):\n\n    # print(v)\n\n    it.total = it.total + r + g + b\n\n    print(it.counter)\n\nprint(it.out)\n\n\n\n# output:\n\n# print(it.out)\n\n# {'total': 10350}\n\n###########################################################\n\n# Merge nested dicts and iterrate (keys/value pairs) without loosing data (values are joined and not overwritten)\n\npeople = {\n\n    1: {\"name\": \"John\", \"age\": \"27\", \"sex\": \"Male\"},\n\n    2: {\"name\": \"Marie\", \"age\": \"22\", \"sex\": \"Female\"},\n\n    3: {\"name\": \"Luna\", \"age\": \"24\", \"sex\": \"Female\"},\n\n    4: {\n\n        \"name\": \"Peter\",\n\n        \"age\": \"29\",\n\n        \"sex\": [\"Female\", \"Male\"],\n\n        1: \"xx\",\n\n        \"sex2\": (\"Female\", \"Male\"),\n\n    },\n\n}\n\n\n\npeople3 = {\n\n    1: {\"namexxxxxxxxx\": \"John\", \"age\": \"27\", \"sex\": \"Male\"},\n\n    2: {\"name\": \"Marie\", \"age\": \"22\", \"sex\": \"Female\"},\n\n    3: {\"name\": \"Luna\", \"agexxxxxxxxxx\": \"24\", \"sex\": \"Female\"},\n\n    4: {\n\n        \"name\": \"Peter\",\n\n        \"age\": \"29\",\n\n        \"sex\": [\"Female\", \"Male\"],\n\n        1: \"xx\",\n\n        \"sex2\": (\"Female\", \"Male\"),\n\n    },\n\n}\n\npeople2 = {\n\n    11: {\"name\": \"Johnaaa\", \"age\": \"2x337\", \"sex\": \"Maleooo\"},\n\n    21: {\"name\": \"Mariexx\", \"age\": \"22\", \"sex\": \"Female\"},\n\n    13: {\"name\": \"Luna\", \"age\": \"24444\", \"sex\": \"Feoomale\"},\n\n    14: {\n\n        \"name\": \"Peter\",\n\n        \"age\": \"29\",\n\n        \"sex\": [\"Female\", \"Male\"],\n\n        111: \"xx\",\n\n        \"sex2\": (\"Female\", \"Male\"),\n\n    },\n\n}\n\nd1 = {1: {\"a\": \"A\"}, 2: {\"b\": \"B\"}}\n\n\n\nd2 = {2: {\"c\": \"C\"}, 3: {\"d\": [\"D\", \"dd\", \"s\"]}}\n\n\n\ndict1 = {1: {\"a\": 1}, 2: {\"b\": 2}}\n\n\n\ndict2 = {2: {\"c\": 222}, 3: {\"d\": {3, 6}}}\n\n\n\ndata2 = {\"A\": [4, 5, 6]}\n\n\n\nfor (\n\n    keys,\n\n    item,\n\n) in iter_join_dicts_no_loss(people, people2, d1, d2, dict2, dict1, data2, people3):\n\n    print(keys, item)\n\n\n\n# output:\n\n# ...\n\n# (1, 14, 'sex', 1) Male\n\n# (1, 14, 111) xx\n\n# (1, 14, 'sex2', 0) Female\n\n# (1, 14, 'sex2', 1) Male\n\n# (2, 1, 'a') A\n\n# (2, 2, 'b') B\n\n# (3, 2, 'c') C\n\n# (3, 3, 'd', 0) D\n\n# (3, 3, 'd', 1) dd\n\n# ...\n\n\n\n###########################################################\n\n# get free file names (enumeration)\n\nfor ini, fi in enumerate(\n\n    iter_get_free_filenames(\n\n        folder=\"f:\\\\testfiles\", fileextension=\".txt\", leadingzeros=5\n\n    )\n\n):\n\n    with open(fi, mode=\"w\", encoding=\"utf-8\") as f:\n\n        f.write(\"\")\n\n    if ini == 5:\n\n        break\n\n    print(fi)\n\n\n\n# output:\n\n# f:\\testfiles\\00002.txt\n\n# f:\\testfiles\\00003.txt\n\n# f:\\testfiles\\00004.txt\n\n# f:\\testfiles\\00005.txt\n\n# f:\\testfiles\\00006.txt\n\n#\n\n###########################################################\n\n# log split for iterables\n\nfor li in iter_log_split(list(range(20))):\n\n    print(li)\n\n\n\n# output:\n\n# [0]\n\n# [1, 2]\n\n# [3, 4, 5]\n\n# [6, 7, 8, 9]\n\n# [10, 11, 12, 13, 14]\n\n# [15, 16, 17, 18, 19]\n\n###########################################################\n\n# Iterate through a nested dict (keys/value pairs) and update\n\n# the values in the original dict\n\ndictoriginal = data = {\n\n    \"level1\": {\n\n        \"t1\": {\n\n            \"s1\": {\"col1\": 5, \"col2\": 4, \"col3\": 4, \"col4\": 9},\n\n            \"s2\": {\"col1\": 1, \"col2\": 5, \"col3\": 4, \"col4\": 8},\n\n            \"s3\": {\"col1\": 11, \"col2\": 8, \"col3\": 2, \"col4\": 9},\n\n            \"s4\": {\"col1\": 5, \"col2\": 4, \"col3\": 4, \"col4\": 9},\n\n        },\n\n        \"t2\": {\n\n            \"s1\": {\"col1\": 5, \"col2\": 4, \"col3\": 4, \"col4\": 9},\n\n            \"s2\": {\"col1\": 1, \"col2\": 5, \"col3\": 4, \"col4\": 8},\n\n            \"s3\": {\"col1\": 11, \"col2\": 8, \"col3\": 2, \"col4\": 9},\n\n            \"s4\": {\"col1\": 5, \"col2\": 4, \"col3\": 4, \"col4\": 9},\n\n        },\n\n    }\n\n}\n\nfor keys, value, setvalue in iter_nested_dict_to_edit(dictoriginal):\n\n    if keys[-1] == \"col1\":\n\n        if isinstance(value, int):\n\n            if value > 4:\n\n                setvalue(10000)\n\n            else:\n\n                setvalue(555)\n\n\n\n# output:\n\n\n\n# dictoriginal # changes the original dict!\n\n# Out[16]:\n\n# {'level1': {'t1': {'s1': {'col1': 10000, 'col2': 4, 'col3': 4, 'col4': 9},\n\n#    's2': {'col1': 555, 'col2': 5, 'col3': 4, 'col4': 8},\n\n#    's3': {'col1': 10000, 'col2': 8, 'col3': 2, 'col4': 9},\n\n#    's4': {'col1': 10000, 'col2': 4, 'col3': 4, 'col4': 9}},\n\n#   't2': {'s1': {'col1': 10000, 'col2': 4, 'col3': 4, 'col4': 9},\n\n#    's2': {'col1': 555, 'col2': 5, 'col3': 4, 'col4': 8},\n\n#    's3': {'col1': 10000, 'col2': 8, 'col3': 2, 'col4': 9},\n\n#    's4': {'col1': 10000, 'col2': 4, 'col3': 4, 'col4': 9}}}}\n\n###########################################################\n\nargs = [0], [1, 2, 3, 4], [5, 6], [7, 8, 9, 10, 11, 12, 13]\n\nvad = list(iter_adjust_list_same_common_size_without_cutting(*args))\n\nfor indexno, itemno, multiplicated_item in vad:\n\n    print(indexno, itemno, multiplicated_item)\n\n\n\n\n\n# output:\n\n# All items have been adjusted to 28 items (lowest common value that can be divided by the length of all lists), nothing has been cut off\n\n# 0 0 [(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)]\n\n# 0 1 [(1, 1, 1, 1, 1, 1, 1), (2, 2, 2, 2, 2, 2, 2), (3, 3, 3, 3, 3, 3, 3), (4, 4, 4, 4, 4, 4, 4)]\n\n# 0 2 [(5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5), (6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6)]\n\n# 0 3 [(7, 7, 7, 7), (8, 8, 8, 8), (9, 9, 9, 9), (10, 10, 10, 10), (11, 11, 11, 11), (12, 12, 12, 12), (13, 13, 13, 13)]\n\n###########################################################\n\n# same as iter_adjust_list_same_common_size_without_cutting, but zipped\n\nvad2 = list(iter_adjust_list_same_common_size_without_cutting_zipped(*args))\n\nfor indexno, itemno, multiplicated_item in vad2:\n\n    print(indexno, itemno, multiplicated_item, end=\"|\")\n\n# output:\n\n# 0 0 [(0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,)]\n\n# 0 1 [(1, 2, 3, 4), (1, 2, 3, 4), (1, 2, 3, 4), (1, 2, 3, 4), (1, 2, 3, 4), (1, 2, 3, 4), (1, 2, 3, 4)]\n\n# 0 2 [(5, 6), (5, 6), (5, 6), (5, 6), (5, 6), (5, 6), (5, 6), (5, 6), (5, 6), (5, 6), (5, 6), (5, 6), (5, 6), (5, 6)]\n\n# 0 3 [(7, 8, 9, 10, 11, 12, 13), (7, 8, 9, 10, 11, 12, 13), (7, 8, 9, 10, 11, 12, 13), (7, 8, 9, 10, 11, 12, 13)]\n\n###########################################################\n\n# returns a single list with adjusted length of every item\n\nvad3 = list(iter_adjust_list_next_to_each_other_zipped(*args))\n\nfor multiplicated_item in vad3:\n\n    print(multiplicated_item)\n\n\n\n# output:\n\n# [(0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,),\n\n# (1, 2, 3, 4), (1, 2, 3, 4), (1, 2, 3, 4), (1, 2, 3, 4), (1, 2, 3, 4), (1, 2, 3, 4), (1, 2, 3, 4),\n\n# (5, 6), (5, 6), (5, 6), (5, 6), (5, 6), (5, 6), (5, 6), (5, 6), (5, 6), (5, 6), (5, 6), (5, 6), (5, 6), (5, 6), (7, 8, 9, 10, 11, 12, 13),\n\n# (7, 8, 9, 10, 11, 12, 13), (7, 8, 9, 10, 11, 12, 13), (7, 8, 9, 10, 11, 12, 13)]\n\n###########################################################\n\n# returns the first value in every list\n\nvad4 = list(iter_transpose_ajusted_list(*args))\n\nfor multiplicated_item in vad4:\n\n    print(multiplicated_item)\n\n# output:\n\n# (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n\n# 1, 1, 1, 1, 1, 1, 1, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 7, 7, 7, 7)\n\n###########################################################\n\n# equilibrates the quantity of each list item\n\nvad5 = list(iter_equilibrate_zip(*args, maxresults=10))\n\nfor multiplicated_item in vad5:\n\n    print(multiplicated_item, end=\",\")\n\n\n\n# output:\n\n# 0,0,5,6,0,0,1,2,3,4,5,6,0,0,5,6,0,7,8,9,10,11,12,13,0,1,2,3,4,5,6,0,0,5,6,0,0,1,2,3,4,5,6,0,0,5,6,7,8,9,10,11,12,13,0,0,1,2,3,4,5,6,0,0,5,6,0,0,1,2,3,4,5,6,0,7,8,9,10,11,12,13,0,5,6,0,0,1,2,3,4,5,6,0,0,5,6,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,\n\n###########################################################\n\n# Same as iter_equilibrate_zip but without flattening\n\nvad6 = list(int_equilibrate_each_value_zip_keep_list(*args))\n\nfor multiplicated_item in vad6:\n\n    print(multiplicated_item, end=\",\")\n\n# output:\n\n# [0],[0],[5, 6],[0],[0],[1, 2, 3, 4],[5, 6],[0],[0],[5, 6],[0],[7, 8, 9, 10, 11, 12, 13],[0],[1, 2, 3, 4],\n\n# [5, 6],[0],[0],[5, 6],[0],[0],[1, 2, 3, 4],[5, 6],[0],[0],[5, 6],\n\n# [7, 8, 9, 10, 11, 12, 13],[0],[0],[1, 2, 3, 4],[5, 6],[0],[0],[5, 6],[0]\n\n# ,[0],[1, 2, 3, 4],[5, 6],[0],[7, 8, 9, 10, 11, 12, 13],[0],[5, 6],[0],\n\n# [0],[1, 2, 3, 4],[5, 6],[0],[0],[5, 6],[0],[0],[1, 2, 3, 4],[5, 6],\n\n# [7, 8, 9, 10, 11, 12, 13]\n\n###########################################################\n\n# get all ascii characters in different formats\n\nlist(iter_get_ascii_table())\n\n\n\n# output:\n\n# ...\n\n# (b'0xf2', 242, b'\\xc3\\xb2'),\n\n# (b'0xf3', 243, b'\\xc3\\xb3'),\n\n# (b'0xf4', 244, b'\\xc3\\xb4'),\n\n# (b'0xf5', 245, b'\\xc3\\xb5'),\n\n# (b'0xf6', 246, b'\\xc3\\xb6'),\n\n# ...\n\n###########################################################\n\nword, wordlist, wordlist_b = iter_string_to_utf16_byte(word=\"\"\"\u00fc'~\u00e7)\"\"\")\n\n# output:\n\n# word\n\n# Out[18]: b\"\\xfc'~\\xe7)\"\n\n\n\n# wordlist\n\n# Out[19]: [b'\\xfc', b\"'\", b'~', b'\\xe7', b')'] without empty bytes\n\n\n\n# wordlist_b\n\n# Out[20]: [b'\\xfc', b'', b\"'\", b'', b'~', b'', b'\\xe7', b'', b')', b''] # contains empty bytes\n\n###########################################################\n\n# Convert a list of utf-16-le to string\n\nlist(iter_utf16bytestostring([word]))\n\nlist(iter_utf16bytestostring([wordlist]))\n\n\n\n# output:\n\n# Out[21]: [\"\u00fc'~\u00e7)\"]\n\n# Out[22]: [\"\u00fc'~\u00e7)\"]\n\n###########################################################\n\n# converts hex string to binary\n\npattern = [\"0xff\", \"0xde\", \"0xdd\", \"0xaa\"]\n\nbinconv = list(iter_hexstrings2bin(pattern))\n\nprint(binconv)\n\n# convert to np array\n\nbinconvnp = np.frombuffer(b\"\".join(binconv), dtype=\"uint8\")\n\nprint(binconvnp)\n\n\n\n# output:\n\n# [b'\\xff', b'\\xde', b'\\xdd', b'\\xaa']\n\n# [255 222 221 170]\n\n###########################################################\n\n# convert hex to int / int to hex\n\nprint(list(iter_int_to_hex(range(13, 18))))\n\nl = [\"0xd\", \"0xe\", \"0xf\", \"0x10\", \"0x11\"]\n\nprint(list(iter_hex_to_int(l)))\n\n\n\n# output:\n\n# ['0xd', '0xe', '0xf', '0x10', '0x11']\n\n# [13, 14, 15, 16, 17]\n\n###########################################################\n\n# string to binary\n\nii = list(iter_str2bin(binbytes=\"baba\", fill=8))\n\n\n\n# output:\n\n# [b'00000062', b'00000061', b'00000062', b'00000061']\n\n###########################################################\n\n# Use NumPy to split an iterable into n slices\n\na = np.array(list(range(20)))\n\nfor q in iter_split_with_np_in_n_slices(a, n=4):\n\n    print(q)\n\n\n\n# output:\n\n# [0 1 2 3 4]\n\n# [5 6 7 8 9]\n\n# [10 11 12 13 14]\n\n# [15 16 17 18 19]\n\n###########################################################\n\n# Use NumPy to split an iterable into n pieces with a certain size\n\nfor q in iter_split_with_np_in_pieces_of(a, n=4):\n\n    print(q)\n\n\n\n\n\n# output:\n\n# [0 1 2 3]\n\n# [4 5 6 7]\n\n# [8  9 10 11]\n\n# [12 13 14 15]\n\n# [16 17 18 19]\n\n\n\nfor q in iter_split_with_np_in_pieces_of(a, n=10):\n\n    print(q)\n\n\n\n# output:\n\n# [0 1 2 3 4 5 6 7 8 9]\n\n# [10 11 12 13 14 15 16 17 18 19]\n\n###########################################################\n\n# convert data to void (raw)\n\nfor b in iter_convert_np_array_to_v(np.array([1, 2, 3]), contiguous=True):\n\n    print(b)\n\n\n\n# output:\n\n# [b'\\x01' b'\\x00' b'\\x00' b'\\x00']\n\n# [b'\\x02' b'\\x00' b'\\x00' b'\\x00']\n\n# [b'\\x03' b'\\x00' b'\\x00' b'\\x00']\n\n###########################################################\n\n# apply a vectorized function against each item in a NumPy array\n\nlist(\n\n    iter_npapply_vetor_function(\n\n        np.array([10, 20, 30]), function=lambda x, y: re.sub(\"0\", y, str(x)), y=\"222\"\n\n    )\n\n)\n\nbb = np.fromiter(iter_npapply_vetor_function(nparray=a, function=hex), dtype=\"O\")\n\ncc = list(iter_npapply_vetor_function(nparray=bb, function=int, base=16))\n\n\n\n# output:\n\n# ['1222', '2222', '3222']\n\n\n\n# bb\n\n# array(['0x0', '0x1', '0x2', '0x3', '0x4', '0x5', '0x6', '0x7', '0x8',\n\n#        '0x9', '0xa', '0xb', '0xc', '0xd', '0xe', '0xf', '0x10', '0x11',\n\n#        '0x12', '0x13'], dtype=object)\n\n\n\n# cc\n\n# Out[21]: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n\n###########################################################\n\n# Converts a NumPy array to one string\n\na1 = np_array_to_string(\n\n    nparray=np.array([1, 2, 3]).astype(\"S8\"),\n\n    encoding=\"utf-8\",\n\n    errors=\"replace\",\n\n    replace0=True,\n\n)\n\na2 = np_array_to_string(\n\n    nparray=np.array([1, 2, 3]), encoding=\"utf-8\", errors=\"replace\", replace0=True\n\n)\n\na3 = np_array_to_string(\n\n    nparray=np.array([1, 2, 3]).astype(\"f\"),\n\n    encoding=\"utf-8\",\n\n    errors=\"replace\",\n\n    replace0=True,\n\n)\n\n# output\n\n\n\n\n\n# a1\n\n# Out[30]: '123'\n\n# a2\n\n# Out[31]: '\\x01\\x02\\x03'\n\n# a3\n\n# Out[32]: '\ufffd?@@@'\n\n###########################################################\n\n# Search a sequence in a NumPy array\n\nfor k in iter_search_sequence_numpy(\n\n    n := np.array(list(reversed(range(10)))), np.array([3, 2, 1])\n\n):\n\n    print(k, n[k])\n\n\n\n# 6 3\n\n# 7 2\n\n# 8 1\n\n###########################################################\n\n# Finds the lowest common multiplier that every number/list can be divided\n\nprint(get_common_division_multiplier(3, 4, 9))\n\nprint(get_common_division_multiplier([3, 4, 9], [1, 2, 8, 4, 3], [2, 2]))\n\n\n\n# output\n\n# {36: {9: 4, 4: 9, 3: 12}, 108: {9: 12, 4: 27, 3: 36}}\n\n# {30: {5: 6, 3: 10, 2: 15}}\n\n###########################################################\n\n# Copies a list, and shuffles it (original doesn\u2019t change)\n\nfor k in iter_shuffle_copied_list([10, 11, 23]):\n\n    print(k)\n\n\n\n# output\n\n# 23\n\n# 10\n\n# 11\n\n###########################################################\n\n# Shuffles a dict (original doesn\u2019t change)\n\n\n\nfor key, item in shuffle_dict({1: 2, 5: 23, 323: 4}).items():\n\n    print(key, item)\n\n\n\n# output\n\n# 323\n\n# 4\n\n# 5\n\n# 23\n\n# 1\n\n# 2\n\n###########################################################\n\n# Normalizes lists by repeating\n\n# Finds the lowest common multiplier that every number/list can be divided\n\n# No item is left out\n\nfor key, item in cycle_list_until_every_list_fits(\n\n    [4, 5, 6],\n\n    [4, 1],\n\n    maxresults=4,\n\n    append=True,\n\n).items():\n\n    print(key, item)\n\n\n\nfor key, item in cycle_list_until_every_list_fits(\n\n    [4, 5, 6],\n\n    [2, 1],\n\n    [44, 42, 21],\n\n    maxresults=4,\n\n    append=False,\n\n).items():\n\n    print(key, item)\n\n\n\n#\n\n# list(cycle_list_until_every_list_fits([4, 5, 6], [4,1], maxresults=4, append=True, ).items())\n\n# Out[3]:\n\n# [(6,\n\n#   defaultdict(list, {0: [[4, 5, 6], [4, 5, 6]], 1: [[4, 1], [4, 1], [4, 1]]})),\n\n#  (12,\n\n#   defaultdict(list,\n\n#               {0: [[4, 5, 6], [4, 5, 6], [4, 5, 6], [4, 5, 6]],\n\n#                1: [[4, 1], [4, 1], [4, 1], [4, 1], [4, 1], [4, 1]]})),\n\n#  (18,\n\n#   defaultdict(list,\n\n#               {0: [[4, 5, 6],\n\n#                 [4, 5, 6],\n\n#                 [4, 5, 6],\n\n#                 [4, 5, 6],\n\n#                 [4, 5, 6],\n\n#                 [4, 5, 6]],\n\n#                1: [[4, 1],\n\n#                 [4, 1],\n\n#                 [4, 1],\n\n#                 [4, 1],\n\n#                 [4, 1],\n\n#                 [4, 1],\n\n#                 [4, 1],\n\n#                 [4, 1],\n\n#                 [4, 1]]})),\n\n#  (24,\n\n#   defaultdict(list,\n\n#               {0: [[4, 5, 6],\n\n#                 [4, 5, 6],\n\n#                 [4, 5, 6],\n\n#                 [4, 5, 6],\n\n#                 [4, 5, 6],\n\n#                 [4, 5, 6],\n\n#                 [4, 5, 6],\n\n#                 [4, 5, 6]],\n\n#                1: [[4, 1],\n\n#                 [4, 1],\n\n#                 [4, 1],\n\n#                 [4, 1],\n\n#                 [4, 1],\n\n#                 [4, 1],\n\n#                 [4, 1],\n\n#                 [4, 1],\n\n#                 [4, 1],\n\n#                 [4, 1],\n\n#                 [4, 1],\n\n#                 [4, 1]]}))]\n\n#\n\n#\n\n\n\n# list((cycle_list_until_every_list_fits([4, 5, 6], [2,1],[44,42,21], maxresults=2, append=False, ).items()))\n\n# Out[5]:\n\n# [(6,\n\n#   defaultdict(list,\n\n#               {0: [44, 42, 21, 44, 42, 21],\n\n#                1: [4, 5, 6, 4, 5, 6],\n\n#                2: [2, 1, 2, 1, 2, 1]})),\n\n#  (12,\n\n#   defaultdict(list,\n\n#               {0: [44, 42, 21, 44, 42, 21, 44, 42, 21, 44, 42, 21],\n\n#                1: [4, 5, 6, 4, 5, 6, 4, 5, 6, 4, 5, 6],\n\n#                2: [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]}))]\n\n\n\n\n\n###########################################################\n\n# Sorts a dict by keys\n\nsort_dict(di={2: 3, 54: 23, 1: 2})\n\n\n\n# output\n\n# {1: 2, 2: 3, 54: 23}\n\n###########################################################\n\n# Get random values from a list (no repetition)\n\niter_get_random_not_repeating_values(list_=list(range(10)), howmany=4)\n\n# Out[6]: [6, 4, 3, 1]\n\niter_get_random_not_repeating_values(list_=list(range(10)), howmany=4)\n\n# Out[7]: [5, 6, 7, 9]\n\n###########################################################\n\n# Get random values from a list (with repetition limit)\n\niter_get_random_values_with_max_rep(list_=list(range(3)), howmany=9, maxrep=4)\n\n# Out[8]: [1, 1, 0, 0, 0, 2, 2, 2, 1]\n\niter_get_random_values_with_max_rep(list_=list(range(3)), howmany=9, maxrep=4)\n\n# Out[9]: [2, 0, 0, 2, 2, 1, 0, 2, 1]\n\n###########################################################\n\nl = [\"hallo\", \"12hal33\", \"42ha004942r\", \"4204h213\", \"hall000\", \"h\", \"cvwsA\"]\n\nfor _ in (iter_sort_by_item_pos(l, 3,fillvalue='')):\n\n    print(_)\n\n\n\n# output:\n\n# h\n\n# 4204h213\n\n# 12hal33\n\n# 42ha004942r\n\n# hallo\n\n# hall000\n\n# cvwsA\n\n###########################################################\n\n```\n\n\n\n### update 2023-01-26 \n\n```python\n\n######################################################\n\nseq=['hallo','hatschi', 'boot','bobo', 'baba', 'bdoo', 'float', 'boat' ]\n\nprint(groupby_element_pos(pos=0,seq=seq, continue_on_exceptions=True, withindex=False, withvalue=True))\n\n# output: {'h': ['hallo', 'hatschi'], 'b': ['boot', 'bobo', 'baba', 'bdoo', 'boat'], 'f': ['float']}\n\n\n\nprint(groupby_element_pos(pos=1,seq=seq, continue_on_exceptions=True, withindex=False, withvalue=True))\n\n# output: {'a': ['hallo', 'hatschi', 'baba'], 'o': ['boot', 'bobo', 'boat'], 'd': ['bdoo'], 'l': ['float']}\n\n\n\nprint(groupby_element_pos(pos=0,seq=seq, continue_on_exceptions=True, withindex=True, withvalue=True))\n\n# output: {'h': [(0, 'hallo'), (1, 'hatschi')], 'b': [(2, 'boot'), (3, 'bobo'), (4, 'baba'), (5, 'bdoo'), (7, 'boat')], 'f': [(6, 'float')]}\n\n\n\nprint(groupby_element_pos(pos=1,seq=seq, continue_on_exceptions=True, withindex=True, withvalue=True))\n\n# output: {'a': [(0, 'hallo'), (1, 'hatschi'), (4, 'baba')], 'o': [(2, 'boot'), (3, 'bobo'), (7, 'boat')], 'd': [(5, 'bdoo')], 'l': [(6, 'float')]}\n\n\n\n######################################################\n\nseq=['habichdich','hallo','hallihallo','hatschi', 'Game: halo' , 'boot','bobo', 'baba', 'bdoo', 'float', 'boat' ]\n\nprint(groupby_substring(substring='hallo',seq=seq, continue_on_exceptions=True, withindex=False, withvalue=True))\n\n# output: {'hallo': ['hallo', 'hallihallo'], 'ha': ['hatschi'], 'hal': ['Game: halo'], '': ['boot', 'bobo', 'baba', 'bdoo', 'float', 'boat']}\n\n\n\nprint(groupby_substring(substring='hallo',seq=seq, continue_on_exceptions=True, withindex=True, withvalue=True))\n\n# output: {'ha': [(0, 'habichdich'), (3, 'hatschi')], 'hallo': [(1, 'hallo'), (2, 'hallihallo')], 'hal': [(4, 'Game: halo')], '': [(5, 'boot'), (6, 'bobo'), (7, 'baba'), (8, 'bdoo'), (9, 'float'), (10, 'boat')]}\n\n\n\nprint(groupby_substring(substring='hallo',seq=seq, continue_on_exceptions=True, withindex=True, withvalue=False))\n\n# output: {'ha': [0, 3], 'hallo': [1, 2], 'hal': [4], '': [5, 6, 7, 8, 9, 10]}\n\n\n\n######################################################\n\nprint(find_common_start_string(seq=['ha','haaalo','hansa']))\n\n# output: ha\n\n######################################################\n\nprint(find_common_end_string(seq=['hax','haaaloax','hansax']))\n\n# output: ax\n\n######################################################\n\nfrom pprint import pprint\n\nres=group_windows_by_class_name()\n\npprint(res,width=25, compact=True)\n\n# ...\n\n# 'WindowsForms10.Window.20808.app.0.2780b98_r6_ad1': [WindowInfo(pid=18276, title='WindowsForms10.Window.20808.app.0.2780b98_r6_ad1', windowtext='', hwnd=203870, length=1, tid=14100, status='invisible', coords_client=(0, 278, 0, 464), dim_client=(278, 464), coords_win=(1453, 1731, 601, 1065), dim_win=(278, 464), class_name='WindowsForms10.Window.20808.app.0.2780b98_r6_ad1', path='C:\\\\Program Files\\\\Greenshot\\\\Greenshot.exe'),\n\n#                                                      WindowInfo(pid=18276, title='WindowsForms10.Window.20808.app.0.2780b98_r6_ad1', windowtext='', hwnd=269452, length=1, tid=14100, status='invisible', coords_client=(0, 128, 0, 48), dim_client=(128, 48), coords_win=(1730, 1858, 847, 895), dim_win=(128, 48), class_name='WindowsForms10.Window.20808.app.0.2780b98_r6_ad1', path='C:\\\\Program Files\\\\Greenshot\\\\Greenshot.exe'),\n\n#                                                      WindowInfo(pid=18276, title='WindowsForms10.Window.20808.app.0.2780b98_r6_ad1', windowtext='', hwnd=466062, length=1, tid=14100, status='invisible', coords_client=(0, 61, 0, 4), dim_client=(61, 4), coords_win=(1730, 1791, 669, 673), dim_win=(61, 4), class_name='WindowsForms10.Window.20808.app.0.2780b98_r6_ad1', path='C:\\\\Program Files\\\\Greenshot\\\\Greenshot.exe'),\n\n#                                                      WindowInfo(pid=18276, title='WindowsForms10.Window.20808.app.0.2780b98_r6_ad1', windowtext='', hwnd=531594, length=1, tid=14100, status='invisible', coords_client=(0, 196, 0, 114), dim_client=(196, 114), coords_win=(1257, 1453, 919, 1033), dim_win=(196, 114), class_name='WindowsForms10.Window.20808.app.0.2780b98_r6_ad1', path='C:\\\\Program Files\\\\Greenshot\\\\Greenshot.exe'),\n\n# ...\n\n######################################################\n\nres=group_windows_by_coords_client()\n\npprint(res,width=25, compact=True)\n\n# ...\n\n# (0,\n\n#   1,\n\n#   0,\n\n#   1): [WindowInfo(pid=4264, title='GDI+ Hook Window Class', windowtext='G', hwnd=1973524, length=2, tid=18104, status='invisible', coords_client=(0, 1, 0, 1), dim_client=(1, 1), coords_win=(0, 1, 0, 1), dim_win=(1, 1), class_name='GDI+ Hook Window Class', path='C:\\\\Program Files\\\\Just Great Software\\\\RegexBuddy 4\\\\RegexBuddy4.exe'), WindowInfo(pid=7408, title='GDI+ Hook Window Class', windowtext='G', hwnd=196686, length=2, tid=7712, status='invisible', coords_client=(0, 1, 0, 1), dim_client=(1, 1), coords_win=(0, 1, 0, 1), dim_win=(1, 1), class_name='GDI+ Hook Window Class', path='C:\\\\Program Files (x86)\\\\ClipAngel 1.94\\\\ClipAngel.exe'), WindowInfo(pid=8188, title='GDI+ Hook Window Class', windowtext='G', hwnd=660968, length=2, tid=16892, status='invisible', coords_client=(0, 1, 0, 1), dim_client=(1, 1), coords_win=(0, 1, 0, 1), dim_win=(1, 1), class_name='GDI+ Hook Window Class', path='C:\\\\Windows\\\\explorer.exe'), WindowInfo(pid=11824, title='GDI+ Hook Window Class', windowtext='G', hwnd=268808, length=2, tid=1344, status='invisible', coords_client=(0, 1, 0, 1), dim_client=(1, 1), coords_win=(0, 1, 0, 1), dim_win=(1, 1), class_name='GDI+ Hook Window Class', path='C:\\\\Program Files\\\\Notepad++\\\\notepad++.exe'), WindowInfo(pid=18276, title='GDI+ Hook Window Class', windowtext='G', hwnd=203884, length=2, tid=16940, status='invisible', coords_client=(0, 1, 0, 1), dim_client=(1, 1), coords_win=(0, 1, 0, 1), dim_win=(1, 1), class_name='GDI+ Hook Window Class', path='C:\\\\Program Files\\\\Greenshot\\\\Greenshot.exe'), WindowInfo(pid=19288, title='GDI+ Hook Window Class', windowtext='G', hwnd=330702, length=2, tid=5068, status='invisible', coords_client=(0, 1, 0, 1), dim_client=(1, 1), coords_win=(0, 1, 0, 1), dim_win=(1, 1), class_name='GDI+ Hook Window Class', path='C:\\\\Program Files (x86)\\\\Microsoft\\\\Skype for Desktop\\\\Skype.exe'), WindowInfo(pid=19324, title='GDI+ Hook Window Class', windowtext='G', hwnd=658766, length=2, tid=3760, status='invisible', coords_client=(0, 1, 0, 1), dim_client=(1, 1), coords_win=(0, 1, 0, 1), dim_win=(1, 1), class_name='GDI+ Hook Window Class', path='C:\\\\Program Files (x86)\\\\Microsoft\\\\Skype for Desktop\\\\Skype.exe')],\n\n# ...\n\n######################################################\n\nres=group_windows_by_coords_win()\n\npprint(res,width=25, compact=True)\n\n# ...\n\n# (1912, 3848, -8, 1088): [WindowInfo(pid=16160, title='SunAwtFrame', windowtext='Python Console - dfdir', hwnd=1840892, length=23, tid=7456, status='visible', coords_client=(0, 1921, 0, 1080), dim_client=(1921, 1080), coords_win=(1912, 3848, -8, 1088), dim_win=(1936, 1096), class_name='SunAwtFrame', path='C:\\\\Program Files\\\\JetBrains\\\\PyCharm Community Edition 2020.3\\\\bin\\\\pycharm64.exe'),\n\n#                          WindowInfo(pid=16160, title='SunAwtFrame', windowtext='dfdir \u2013 __init__.py Administrator', hwnd=529490, length=34, tid=7456, status='visible', coords_client=(0, 1921, 0, 1080), dim_client=(1921, 1080), coords_win=(1912, 3848, -8, 1088), dim_win=(1936, 1096), class_name='SunAwtFrame', path='C:\\\\Program Files\\\\JetBrains\\\\PyCharm Community Edition 2020.3\\\\bin\\\\pycharm64.exe'),\n\n#                          WindowInfo(pid=16160, title='SunAwtFrame', windowtext='stopjogo \u2013 gp7.py Administrator', hwnd=4459518, length=32, tid=7456, status='visible', coords_client=(0, 1921, 0, 1080), dim_client=(1921, 1080), coords_win=(1912, 3848, -8, 1088), dim_win=(1936, 1096), class_name='SunAwtFrame', path='C:\\\\Program Files\\\\JetBrains\\\\PyCharm Community Edition 2020.3\\\\bin\\\\pycharm64.exe')],\n\n# ...\n\n######################################################\n\nres=group_windows_by_dim_client()\n\npprint(res,width=25, compact=True)\n\n# ...\n\n# (61, 4): [WindowInfo(pid=18276, title='WindowsForms10.Window.20808.app.0.2780b98_r6_ad1', windowtext='', hwnd=466062, length=1, tid=14100, status='invisible', coords_client=(0, 61, 0, 4), dim_client=(61, 4), coords_win=(1730, 1791, 669, 673), dim_win=(61, 4), class_name='WindowsForms10.Window.20808.app.0.2780b98_r6_ad1', path='C:\\\\Program Files\\\\Greenshot\\\\Greenshot.exe'),\n\n#           WindowInfo(pid=18276, title='WindowsForms10.Window.20808.app.0.2780b98_r6_ad1', windowtext='', hwnd=531600, length=1, tid=14100, status='invisible', coords_client=(0, 61, 0, 4), dim_client=(61, 4), coords_win=(1730, 1791, 719, 723), dim_win=(61, 4), class_name='WindowsForms10.Window.20808.app.0.2780b98_r6_ad1', path='C:\\\\Program Files\\\\Greenshot\\\\Greenshot.exe')],\n\n# (67, 20): [WindowInfo(pid=8188, title='tooltips_class32', windowtext='', hwnd=65862, length=1, tid=8200, status='invisible', coords_client=(0, 67, 0, 20), dim_client=(67, 20), coords_win=(1740, 1807, 1049, 1069), dim_win=(67, 20), class_name='tooltips_class32', path='C:\\\\Windows\\\\explorer.exe')],\n\n# ...\n\n######################################################\n\nres=group_windows_by_dim_win()\n\npprint(res,width=25, compact=True)\n\n# ...\n\n# (1936, 1096): [WindowInfo(pid=16160, title='SunAwtFrame', windowtext='Python Console - dfdir', hwnd=1840892, length=23, tid=7456, status='visible', coords_client=(0, 1921, 0, 1080), dim_client=(1921, 1080), coords_win=(1912, 3848, -8, 1088), dim_win=(1936, 1096), class_name='SunAwtFrame', path='C:\\\\Program Files\\\\JetBrains\\\\PyCharm Community Edition 2020.3\\\\bin\\\\pycharm64.exe'),\n\n#                WindowInfo(pid=16160, title='SunAwtFrame', windowtext='stopjogo \u2013 gp7.py Administrator', hwnd=4459518, length=32, tid=7456, status='visible', coords_client=(0, 1921, 0, 1080), dim_client=(1921, 1080), coords_win=(1912, 3848, -8, 1088), dim_win=(1936, 1096), class_name='SunAwtFrame', path='C:\\\\Program Files\\\\JetBrains\\\\PyCharm Community Edition 2020.3\\\\bin\\\\pycharm64.exe')],\n\n# (3840, 1080): [WindowInfo(pid=8188, title='Progman', windowtext='Program Manager', hwnd=131422, length=16, tid=6272, status='visible', coords_client=(0, 3840, 0, 1080), dim_client=(3840, 1080), coords_win=(0, 3840, 0, 1080), dim_win=(3840, 1080), class_name='Progman', path='C:\\\\Windows\\\\explorer.exe')],\n\n# ...\n\n######################################################\n\nres=group_windows_by_path()\n\npprint(res,width=25, compact=True)\n\n\n\n# ...\n\n# 'C:\\\\Windows\\\\System32\\\\notepad.exe': [WindowInfo(pid=7708, title='IME', windowtext='Default IME', hwnd=6621606, length=12, tid=18480, status='invisible', coords_client=(0, 0, 0, 0), dim_client=(0, 0), coords_win=(0, 0, 0, 0), dim_win=(0, 0), class_name='IME', path='C:\\\\Windows\\\\System32\\\\notepad.exe'),\n\n#                                        WindowInfo(pid=7708, title='MSCTFIME UI', windowtext='MSCTFIME UI', hwnd=3016006, length=12, tid=18480, status='invisible', coords_client=(0, 0, 0, 0), dim_client=(0, 0), coords_win=(0, 0, 0, 0), dim_win=(0, 0), class_name='MSCTFIME UI', path='C:\\\\Windows\\\\System32\\\\notepad.exe'),\n\n#                                        WindowInfo(pid=7708, title='Notepad', windowtext='*Untitled - Notepad', hwnd=3998632, length=20, tid=18480, status='visible', coords_client=(0, 1022, 0, 578), dim_client=(1022, 578), coords_win=(242, 1280, 130, 767), dim_win=(1038, 637), class_name='Notepad', path='C:\\\\Windows\\\\System32\\\\notepad.exe')],\n\n# 'C:\\\\Windows\\\\System32\\\\rundll32.exe': [WindowInfo(pid=6652, title='IME', windowtext='Default IME', hwnd=65686, length=12, tid=6656, status='invisible', coords_client=(0, 0, 0, 0), dim_client=(0, 0), coords_win=(0, 0, 0, 0), dim_win=(0, 0), class_name='IME', path='C:\\\\Windows\\\\System32\\\\rundll32.exe'),\n\n#                                         WindowInfo(pid=6652, title='RunDLL', windowtext='', hwnd=1376404, length=1, tid=6656, status='invisible', coords_client=(0, 0, 0, 0), dim_client=(0, 0), coords_win=(78, 94, 78, 94), dim_win=(16, 16), class_name='RunDLL', path='C:\\\\Windows\\\\System32\\\\rundll32.exe'),\n\n#                                         WindowInfo(pid=6652, title='rxDiagRuntimePumpWindowClass', windowtext='RxDiag Message Pump 2.1 Nov 23 2021 07:27:35', hwnd=65688, length=45, tid=6656, status='invisible', coords_client=(0, 360, 0, 57), dim_client=(360, 57), coords_win=(300, 680, 300, 400), dim_win=(380, 100), class_name='rxDiagRuntimePumpWindowClass', path='C:\\\\Windows\\\\System32\\\\rundll32.exe')],\n\n# ...\n\n######################################################\n\nres=group_windows_by_pid()\n\npprint(res,width=25, compact=True)\n\n\n\n# ...\n\n# 3396: [WindowInfo(pid=3396, title='NVSVC64.DLL', windowtext='NvSvc', hwnd=197238, length=6, tid=9536, status='invisible', coords_client=(0, 1424, 0, 728), dim_client=(1424, 728), coords_win=(208, 1648, 208, 975), dim_win=(1440, 767), class_name='NVSVC64.DLL', path='C:\\\\Windows\\\\System32\\\\DriverStore\\\\FileRepository\\\\nv_dispi.inf_amd64_c0e159863e7afdde\\\\Display.NvContainer\\\\NVDisplay.Container.exe'),\n\n#        WindowInfo(pid=3396, title='NvContainerWindowClass00000D44', windowtext='NvContainerWindowClass00000D44', hwnd=65632, length=31, tid=3400, status='invisible', coords_client=(0, 0, 0, 0), dim_client=(0, 0), coords_win=(0, 0, 0, 0), dim_win=(0, 0), class_name='NvContainerWindowClass00000D44', path='C:\\\\Windows\\\\System32\\\\DriverStore\\\\FileRepository\\\\nv_dispi.inf_amd64_c0e159863e7afdde\\\\Display.NvContainer\\\\NVDisplay.Container.exe'),\n\n#        WindowInfo(pid=3396, title='UxdService', windowtext='UxdService', hwnd=131560, length=11, tid=9520, status='invisible', coords_client=(0, 1424, 0, 728), dim_client=(1424, 728), coords_win=(182, 1622, 182, 949), dim_win=(1440, 767), class_name='UxdService', path='C:\\\\Windows\\\\System32\\\\DriverStore\\\\FileRepository\\\\nv_dispi.inf_amd64_c0e159863e7afdde\\\\Display.NvContainer\\\\NVDisplay.Container.exe')],\n\n# 3588: [WindowInfo(pid=3588, title='IME', windowtext='Default IME', hwnd=527634, length=12, tid=17620, status='invisible', coords_client=(0, 0, 0, 0), dim_client=(0, 0), coords_win=(0, 0, 0, 0), dim_win=(0, 0), class_name='IME', path='C:\\\\Program Files (x86)\\\\Microsoft\\\\Skype for Desktop\\\\Skype.exe'),\n\n#        WindowInfo(pid=3588, title='crashpad_SessionEndWatcher', windowtext='', hwnd=986134, length=1, tid=17620, status='invisible', coords_client=(0, 130, 0, 10), dim_client=(130, 10), coords_win=(0, 136, 0, 39), dim_win=(136, 39), class_name='crashpad_SessionEndWatcher', path='C:\\\\Program Files (x86)\\\\Microsoft\\\\Skype for Desktop\\\\Skype.exe')],\n\n# ...\n\n######################################################\n\nres=group_windows_by_status()\n\npprint(res,width=25, compact=True)\n\n\n\n# ...\n\n#{'invisible': [WindowInfo(pid=648, title='COMTASKSWINDOWCLASS', windowtext='Task Host Window', hwnd=131108, length=17, tid=688, status='invisible', coords_client=(0, 120, 0, 0), dim_client=(120, 0), coords_win=(0, 136, 0, 39), dim_win=(136, 39), class_name='COMTASKSWINDOWCLASS', path='C:\\\\Windows\\\\System32\\\\taskhostw.exe'),\n\n#               WindowInfo(pid=648, title='CicLoaderWndClass', windowtext='', hwnd=65722, length=1, tid=700, status='invisible', coords_client=(0, 120, 0, 0), dim_client=(120, 0), coords_win=(0, 136, 0, 39), dim_win=(136, 39), class_name='CicLoaderWndClass', path='C:\\\\Windows\\\\System32\\\\taskhostw.exe'),\n\n# ...\n\n######################################################              \n\n\n\nres=group_windows_by_tid()\n\npprint(res,width=25, compact=True)\n\n# ...\n\n# 19160: [WindowInfo(pid=18720, title='IME', windowtext='Default IME', hwnd=1252582, length=12, tid=19160, status='invisible', coords_client=(0, 0, 0, 0), dim_client=(0, 0), coords_win=(0, 0, 0, 0), dim_win=(0, 0), class_name='IME', path='C:\\\\Windows\\\\System32\\\\conhost.exe')],\n\n# 20820: [WindowInfo(pid=1664, title='Chrome_WidgetWin_0', windowtext='', hwnd=3481304, length=1, tid=20820, status='invisible', coords_client=(0, 0, 0, 0), dim_client=(0, 0), coords_win=(0, 0, 0, 0), dim_win=(0, 0), class_name='Chrome_WidgetWin_0', path='C:\\\\Program Files (x86)\\\\Google\\\\Chrome\\\\Application\\\\chrome.exe'),\n\n#         WindowInfo(pid=1664, title='IME', windowtext='Default IME', hwnd=4396660, length=12, tid=20820, status='invisible', coords_client=(0, 0, 0, 0), dim_client=(0, 0), coords_win=(0, 0, 0, 0), dim_win=(0, 0), class_name='IME', path='C:\\\\Program Files (x86)\\\\Google\\\\Chrome\\\\Application\\\\chrome.exe')]}\n\n# ...\n\n######################################################              \n\nres=group_windows_by_title()\n\npprint(res,width=25, compact=True)\n\n# ...\n\n# '_SearchEditBoxFakeWindow': [WindowInfo(pid=8188, title='_SearchEditBoxFakeWindow', windowtext='', hwnd=2039638, length=1, tid=14128, status='invisible', coords_client=(0, 0, 0, 0), dim_client=(0, 0), coords_win=(0, 0, 0, 0), dim_win=(0, 0), class_name='_SearchEditBoxFakeWindow', path='C:\\\\Windows\\\\explorer.exe'),\n\n#                              WindowInfo(pid=8188, title='_SearchEditBoxFakeWindow', windowtext='', hwnd=2825750, length=1, tid=4980, status='invisible', coords_client=(0, 0, 0, 0), dim_client=(0, 0), coords_win=(0, 0, 0, 0), dim_win=(0, 0), class_name='_SearchEditBoxFakeWindow', path='C:\\\\Windows\\\\explorer.exe'),\n\n#                              WindowInfo(pid=18984, title='_SearchEditBoxFakeWindow', windowtext='', hwnd=266452, length=1, tid=15264, status='invisible', coords_client=(0, 0, 0, 0), dim_client=(0, 0), coords_win=(0, 0, 0, 0), dim_win=(0, 0), class_name='_SearchEditBoxFakeWindow', path='C:\\\\Windows\\\\explorer.exe')],\n\n# 'crashpad_SessionEndWatcher': [WindowInfo(pid=3588, title='crashpad_SessionEndWatcher', windowtext='', hwnd=986134, length=1, tid=17620, status='invisible', coords_client=(0, 130, 0, 10), dim_client=(130, 10), coords_win=(0, 136, 0, 39), dim_win=(136, 39), class_name='crashpad_SessionEndWatcher', path='C:\\\\Program Files (x86)\\\\Microsoft\\\\Skype for Desktop\\\\Skype.exe'),\n\n#                                WindowInfo(pid=12872, title='crashpad_SessionEndWatcher', windowtext='', hwnd=464830, length=1, tid=12688, status='invisible', coords_client=(0, 130, 0, 10), dim_client=(130, 10), coords_win=(0, 136, 0, 39), dim_win=(136, 39), class_name='crashpad_SessionEndWatcher', path='C:\\\\Program Files\\\\Krisp\\\\WebView2\\\\msedgewebview2.exe'),\n\n#                                WindowInfo(pid=13436, title='crashpad_SessionEndWatcher', windowtext='', hwnd=4194640, length=1, tid=11620, status='invisible', coords_client=(0, 130, 0, 10), dim_client=(130, 10), coords_win=(0, 136, 0, 39), dim_win=(136, 39), class_name='crashpad_SessionEndWatcher', path='C:\\\\Program Files (x86)\\\\Google\\\\Chrome\\\\Application\\\\chrome.exe'),\n\n#                               WindowInfo(pid=20928, title='crashpad_SessionEndWatcher', windowtext='', hwnd=464914, length=1, tid=14920, status='invisible', coords_client=(0, 130, 0, 10), dim_client=(130, 10), coords_win=(0, 136, 0, 39), dim_win=(136, 39), class_name='crashpad_SessionEndWatcher', path='C:\\\\Program Files\\\\Krisp\\\\WebView2\\\\msedgewebview2.exe')],\n\n# ...\n\n######################################################    \n\n\n\nres=group_windows_by_windowtext()\n\nfrom pprint import pprint\n\npprint(res,width=25, compact=True)\n\n# ...\n\n# 'GitHub Desktop': [WindowInfo(pid=17556, title='Chrome_WidgetWin_1', windowtext='GitHub Desktop', hwnd=5966550, length=15, tid=12196, status='visible', coords_client=(0, 960, 0, 660), dim_client=(960, 660), coords_win=(669, 1629, 123, 783), dim_win=(960, 660), class_name='Chrome_WidgetWin_1', path='C:\\\\Users\\\\Gamer\\\\AppData\\\\Local\\\\GitHubDesktop\\\\app-3.1.4\\\\GitHubDesktop.exe')],\n\n# 'Greenshot - the revolutionary screenshot utility': [WindowInfo(pid=18276, title='WindowsForms10.Window.8.app.0.2780b98_r6_ad1', windowtext='Greenshot - the revolutionary screenshot utility', hwnd=597088, length=49, tid=14100, status='invisible', coords_client=(0, 0, 0, 0), dim_client=(0, 0), coords_win=(-32000, -31840, -32000, -31972), dim_win=(160, 28), class_name='WindowsForms10.Window.8.app.0.2780b98_r6_ad1', path='C:\\\\Program Files\\\\Greenshot\\\\Greenshot.exe')],\n\n# 'Hidden Window': [WindowInfo(pid=10876, title='HwndWrapper[Krisp.exe;;773b0141-7627-46a3-8fd7-70ae4b8b3669]', windowtext='Hidden Window', hwnd=399360, length=14, tid=19056, status='invisible', coords_client=(0, 1424, 0, 728), dim_client=(1424, 728), coords_win=(156, 1596, 156, 923), dim_win=(1440, 767), class_name='HwndWrapper[Krisp.exe;;773b0141-7627-46a3-8fd7-70ae4b8b3669]', path='C:\\\\Program Files\\\\Krisp\\\\Krisp.exe'),\n\n#                   WindowInfo(pid=10876, title='HwndWrapper[Krisp.exe;;c309ef14-1945-423d-9140-f7e8760938b5]', windowtext='Hidden Window', hwnd=395536, length=14, tid=19056, status='invisible', coords_client=(0, 1424, 0, 728), dim_client=(1424, 728), coords_win=(208, 1648, 208, 975), dim_win=(1440, 767), class_name='HwndWrapper[Krisp.exe;;c309ef14-1945-423d-9140-f7e8760938b5]', path='C:\\\\Program Files\\\\Krisp\\\\Krisp.exe')],\n\n# ...\n\n######################################################    \n\nv = [r\"baba\", r\"baba\", r\"bubu\", 3,4,5]\n\nprint(group_vars_by_hash(seq=v, continue_on_exceptions=True, withindex=False, withvalue=True))\n\n# output: {-7914231873912742807: ['baba', 'baba'], -6908341703943681820: ['bubu'], 3: [3], 4: [4], 5: [5]}\n\n\n\nprint(group_vars_by_hash(seq=v, continue_on_exceptions=True, withindex=True, withvalue=True))\n\n# output: {-7914231873912742807: [(0, 'baba'), (1, 'baba')], -6908341703943681820: [(2, 'bubu')], 3: [(3, 3)], 4: [(4, 4)], 5: [(5, 5)]}\n\n\n\n######################################################    \n\nfiles = [r\"F:\\00401 - Copy.jpg\", r\"F:\\00401.jpg\", r\"F:\\bw_pic.png\", ]\n\ngroup_files_by_hash(seq=files,continue_on_exceptions=True, withindex=True, withvalue=True)\n\n# {'6d7ca5ec1deb81e4a127719a7b1b3328': ['F:\\\\00401 - Copy.jpg', 'F:\\\\00401.jpg'],\n\n#  'fab1479078ac767ec468b28425f5069a': ['F:\\\\bw_pic.png']}\n\n######################################################\n\n```\n\n## groupby stuff \n\n\n\n```python\n\n\n\n\n\n######################################################\n\n# Almost all groupby functions accept the kwargs: continue_on_exceptions, withindex, withvalue\n\n\n\n\n\n# continue_on_exceptions=True - Exceptions are pulled, and each Exception gets its own group\n\nprint(groupby_can_be_divided_by(\n\n    div=2, seq=([\"1\", 1, 3, 3, 3, 5, 3, 5, 22.22, *(3, 4), *[333, 4]]), continue_on_exceptions=True, withindex=False, withvalue=True\n\n))\n\n# output: {'EXCEPTION: not all arguments converted during string formatting': ['1'],\n\n# False: [1, 3, 3, 3, 5, 3, 5, 22.22, 3, 333],\n\n# True: [4, 4]}\n\n \n\n######################################################\n\n# withindex=True - Returns the index and the value of the input list:\n\nprint(groupby_can_be_divided_by(\n\n    div=2, seq=([\"1\", 1, 3, 3, 3, 5, 3, 5, 22.22, *(3, 4), *[333, 4]]), continue_on_exceptions=True, withindex=True, withvalue=True\n\n))\n\n\n\n# output:{'EXCEPTION: not all arguments converted during string formatting': [(0, '1')], \n\n#  False: [(1, 1), (2, 3), (3, 3), (4, 3), (5, 5), (6, 3), (7, 5), (8, 22.22), (9, 3), (11, 333)], \n\n#  True: [(10, 4), (12, 4)]}\n\n\n\n\n\n######################################################\n\n# withvalue=False - Only the index of the input list is returned:\n\n# output: {'EXCEPTION: not all arguments converted during string formatting': [0], \n\n# False: [1, 2, 3, 4, 5, 6, 7, 8, 9, 11],\n\n# True: [10, 12]}\n\n######################################################\n\n\n\n```\n\n\n\n\n\n\n\n```python\n\n######################################################\n\nprint(list(iter_2_cycle_second_until_first_done(iter1=[3, 3, 4, 4], iter2=[1, 2])))\n\n# output: [(3, 1), (3, 2), (4, 1), (4, 2)]\n\n######################################################\n\nprint(groupby_euclid_dist(\n\n    coord=(50, 100),\n\n    seq=[(100, 100), (300, 500), (900, 23), (10, 10)],\n\n    mindistance=0,\n\n    maxdistance=500,\n\n))\n\n\n\n# output: {True: [(100, 100), (300, 500), (10, 10)], False: [(900, 23)]}\n\n######################################################\n\nprint(groupby_string_length(\n\n    seq=[\"dd\", \"b\", \"ff\", \"saaa\"],\n\n))\n\n\n\n# output: {2: ['dd', 'ff'], 1: ['b'], 4: ['saaa']}\n\n######################################################\n\nprint(group_values_in_flattened_nested_iter_and_count(seq=[1,2,3,4,[33,412,2,2,3], {(3,4), (1,4)}], continue_on_exceptions=True, withindex=False, withvalue=True\n\n))\n\n# output: {1: 2, 2: 3, 3: 3, 4: 3, 33: 1, 412: 1}\n\n######################################################\n\n\n\nprint(groupby_type(seq=[\"dd\", \"b\", \"ff\", \"saaa\", 1, 3, 5, 22.22, (3, 4), [333, 4]]))\n\n# output: {<class 'str'>: ['dd', 'b', 'ff', 'saaa'], <class 'int'>: [1, 3, 5], <class 'float'>: [22.22], <class 'tuple'>: [(3, 4)], <class 'list'>: [[333, 4]]}\n\n######################################################\n\nprint(groupby_frequency(\n\n    seq=[\n\n        \"dd\",\n\n        \"b\",\n\n        \"ff\",\n\n        \"saaa\",\n\n        1,\n\n        3,\n\n        3,\n\n        3,\n\n        5,\n\n        \"b\",\n\n        3,\n\n        5,\n\n        22.22,\n\n        (3, 4),\n\n        [333, 4],\n\n    ]\n\n))\n\n# output: {1: ['dd', 'ff', 'saaa', 1, 22.22, (3, 4), [333, 4]], 2: ['b', 5, 'b', 5], 4: [3, 3, 3, 3]}\n\n######################################################\n\nprint(groupby_division_remainder(\n\n    div=2, seq=([1, 3, 3, 3, 5, 3, 5, 22.22, *(3, 4), *[333, 4]])\n\n))\n\n# output: {1: [1, 3, 3, 3, 5, 3, 5, 3, 333], 0.21999999999999886: [22.22], 0: [4, 4]}\n\n######################################################\n\nprint(groupby_divisor(\n\n    div=2, seq=([1, 3, 3, 3, 5, 3, 5, 22.22, *(3, 4), *[333, 4]])\n\n))\n\n# output: {0: [1], 1: [3, 3, 3, 3, 3], 2: [5, 5, 4, 4], 11.0: [22.22], 166: [333]}\n\n######################################################\n\nprint(groupby_less_than_or_equal(\n\n    number=2,\n\n    seq=([1, 3, 3, 3, 5, 3,2,2, 5, 22.22, *(3, 4), *[333, 4]]),\n\n    continue_on_exceptions=True,\n\n    withindex=False,\n\n))\n\n# output: {True: [1, 2, 2], False: [3, 3, 3, 5, 3, 5, 22.22, 3, 4, 333, 4]}\n\n######################################################\n\nprint(groupby_less_than(\n\n    number=2,\n\n    seq=([1, 3, 3, 3, 5, 3, 5, 22.22, *(3, 4), *[333, 4]]),\n\n    continue_on_exceptions=True,\n\n    withindex=False,\n\n))\n\n# output: {True: [1], False: [3, 3, 3, 5, 3, 5, 22.22, 3, 4, 333, 4]}\n\n######################################################\n\nprint(groupby_bigger_than_or_equal(\n\n    number=2,\n\n    seq=([1, 3, 3, 3, 5, 3, 2,2,2,5, 22.22, *(3, 4), *[333, 4]]),\n\n    continue_on_exceptions=True,\n\n    withindex=False,\n\n))\n\n# output: {False: [1], True: [3, 3, 3, 5, 3, 2, 2, 2, 5, 22.22, 3, 4, 333, 4]}\n\n######################################################\n\nprint(groupby_bigger_than(\n\n    number=2,\n\n    seq=([\"1\", 1, 3, 3, 3, 5, 3, 5, 22.22, *(3, 4), *[333, 4]]),\n\n    continue_on_exceptions=True,\n\n    withindex=False,\n\n))\n\n# output: {\"EXCEPTION: '>' not supported between instances of 'str' and 'int'\": ['1'], False: [1], True: [3, 3, 3, 5, 3, 5, 22.22, 3, 4, 333, 4]}\n\n######################################################\n\nprint(groupby_equal(\n\n    number=3,\n\n    seq=([\"1\", 1, 3, 3, 3, 5, 3, 5, 22.22, *(3, 4), *[333, 4]]),\n\n    continue_on_exceptions=True,\n\n    withindex=False,\n\n))\n\n# output: {False: ['1', 1, 5, 5, 22.22, 4, 333, 4], True: [3, 3, 3, 3, 3]}\n\n######################################################\n\nprint(groupby_regular_expression_matches(\n\n    regexpressions=[r\"^\\d+$\", '^A+$'],\n\n    seq=([1, 3, 3, 3, 5, 3, 5,'AA', 'BB', 22.22, *(3, 4), *[333, 4]]),\n\n    continue_on_exceptions=True,\n\n    withindex=False,\n\n))\n\n\n\n# output: {True: [1, 3, 3, 3, 5, 3, 5, 'AA', 3, 4, 333, 4], False: ['BB', 22.22]}\n\n######################################################\n\nprint(groupby_is_integer(\n\n    seq=[2.0,1,1,3,5,3.0, 3.4,2.4,25.3], continue_on_exceptions=True, withindex=False, withvalue=True))\n\n# output: {True: [2.0, 1, 1, 3, 5, 3.0], False: [3.4, 2.4, 25.3]}\n\n######################################################\n\nprint(groupby_floor(\n\n    seq=[1.0,1.1,1.2,1.3,1.9,1.8,2.0,1,1,3,5,3.0, 3.4,2.4,25.3], continue_on_exceptions=True, withindex=False, withvalue=True\n\n))\n\n# output: {1: [1.0, 1.1, 1.2, 1.3, 1.9, 1.8, 1, 1], 2: [2.0, 2.4], 3: [3, 3.0, 3.4], 5: [5], 25: [25.3]}\n\n######################################################\n\nprint(groupby_ceil(\n\n    seq=[1.0,1.1,1.2,1.3,1.9,1.8,2.0,1,1,3,5,3.0, 3.4,2.4,25.3], continue_on_exceptions=True, withindex=False, withvalue=True\n\n))\n\n# output: {1: [1.0, 1, 1], 2: [1.1, 1.2, 1.3, 1.9, 1.8, 2.0], 3: [3, 3.0, 2.4], 5: [5], 4: [3.4], 26: [25.3]}\n\n######################################################\n\nprint(groupby_round(n=2,\n\n    seq=[1.11111111,1.111222222,1.11113334,1.3,1.9,1.8,2.0,1,1,3,5,3.0, 3.4,2.4,25.3], continue_on_exceptions=True, withindex=False, withvalue=True\n\n))\n\n# output: {1.11: [1.11111111, 1.111222222, 1.11113334], 1.3: [1.3], 1.9: [1.9], 1.8: [1.8], 2.0: [2.0], 1: [1, 1], 3: [3, 3.0], 5: [5], 3.4: [3.4], 2.4: [2.4], 25.3: [25.3]}\n\n######################################################\n\nprint(groupby_endswith(\n\n    n=1,seq=['hallo', 'boot', 'baba', 'bdoo', 'flaot', 'mama' ], continue_on_exceptions=True, withindex=False, withvalue=True\n\n))\n\n# output: {'o': ['hallo', 'bdoo'], 't': ['boot', 'flaot'], 'a': ['baba', 'mama']}\n\n######################################################\n\nprint(groupby_startswith(\n\n    n=1,seq=['hallo', 'boot', 'baba', 'bdoo', 'flaot', 'hmama' ], continue_on_exceptions=True, withindex=False, withvalue=True\n\n))\n\n# output: {'h': ['hallo', 'hmama'], 'b': ['boot', 'baba', 'bdoo'], 'f': ['flaot']}\n\n\n\nprint(groupby_startswith(\n\n    n=1,seq=['hallo', 'boot', 'baba', 'bdoo', 'flaot', 'hmama' ], continue_on_exceptions=True, withindex=True, withvalue=False\n\n))\n\n# output: {'h': [0, 5], 'b': [1, 2, 3], 'f': [4]}\n\n\n\nprint(groupby_startswith(\n\n    n=1,seq=['hallo', 'boot', 'baba', 'bdoo', 'flaot', 'hmama' ], continue_on_exceptions=True, withindex=True, withvalue=True\n\n))\n\n# output: {'h': [(0, 'hallo'), (5, 'hmama')], 'b': [(1, 'boot'), (2, 'baba'), (3, 'bdoo')], 'f': [(4, 'flaot')]}\n\n######################################################\n\nprint(groupby_first_occurrence_in_string(\n\n    char='a',seq=['hallo', 'boot', 'baba', 'bdoo', 'flaot', 'hmama' ], continue_on_exceptions=True, withindex=False, withvalue=True\n\n))\n\n# output: {1: ['hallo', 'baba'], -1: ['boot', 'bdoo'], 2: ['flaot', 'hmama']}\n\n######################################################\n\nprint(groupby_last_occurrence_in_string(\n\n    char='a',seq=['hallo', 'boot', 'baba', 'bdoo', 'flaot', 'hmama' ], continue_on_exceptions=True, withindex=False, withvalue=True\n\n))\n\n# output: {1: ['hallo'], -1: ['boot', 'bdoo'], 3: ['baba'], 2: ['flaot'], 4: ['hmama']}\n\n######################################################\n\ntext = '''One evening, a few days later, K. was walking along one of the corridors that separated his office from the main stairway\u2014he was nearly the last one to leave for home that evening, there remained only a couple of workers in the light of a single bulb in the dispatch department\u2014when he heard a sigh from behind a door which he had himself never opened but which he had always thought just led into a junk room. He stood in amazement and listened again to establish whether he might not be mistaken'''.split()\n\nprint(groupby_isalnum(\n\n    seq=text, continue_on_exceptions=True, withindex=False, withvalue=True\n\n))\n\n# output: {True: ['One', 'a', 'few', 'days', 'was', 'walking', 'along', 'one', 'of', 'the', 'corridors', 'that', 'separated', 'his', 'office', 'from', 'the', 'main', 'was', 'nearly', 'the', 'last', 'one', 'to', 'leave', 'for', 'home', 'that', 'there', 'remained', 'only', 'a', 'couple', 'of', 'workers', 'in', 'the', 'light', 'of', 'a', 'single', 'bulb', 'in', 'the', 'dispatch', 'he', 'heard', 'a', 'sigh', 'from', 'behind', 'a', 'door', 'which', 'he', 'had', 'himself', 'never', 'opened', 'but', 'which', 'he', 'had', 'always', 'thought', 'just', 'led', 'into', 'a', 'junk', 'He', 'stood', 'in', 'amazement', 'and', 'listened', 'again', 'to', 'establish', 'whether', 'he', 'might', 'not', 'be', 'mistaken'], False: ['evening,', 'later,', 'K.', 'stairway\u2014he', 'evening,', 'department\u2014when', 'room.']}\n\n######################################################\n\nprint(groupby_isalpha(\n\n    seq=text, continue_on_exceptions=True, withindex=False, withvalue=True\n\n))\n\n# output: {True: ['One', 'a', 'few', 'days', 'was', 'walking', 'along', 'one', 'of', 'the', 'corridors', 'that', 'separated', 'his', 'office', 'from', 'the', 'main', 'was', 'nearly', 'the', 'last', 'one', 'to', 'leave', 'for', 'home', 'that', 'there', 'remained', 'only', 'a', 'couple', 'of', 'workers', 'in', 'the', 'light', 'of', 'a', 'single', 'bulb', 'in', 'the', 'dispatch', 'he', 'heard', 'a', 'sigh', 'from', 'behind', 'a', 'door', 'which', 'he', 'had', 'himself', 'never', 'opened', 'but', 'which', 'he', 'had', 'always', 'thought', 'just', 'led', 'into', 'a', 'junk', 'He', 'stood', 'in', 'amazement', 'and', 'listened', 'again', 'to', 'establish', 'whether', 'he', 'might', 'not', 'be', 'mistaken'], False: ['evening,', 'later,', 'K.', 'stairway\u2014he', 'evening,', 'department\u2014when', 'room.']}\n\n######################################################\n\nprint(groupby_isascii(\n\n    seq=text, continue_on_exceptions=True, withindex=False, withvalue=True\n\n))\n\n# output: {True: ['One', 'evening,', 'a', 'few', 'days', 'later,', 'K.', 'was', 'walking', 'along', 'one', 'of', 'the', 'corridors', 'that', 'separated', 'his', 'office', 'from', 'the', 'main', 'was', 'nearly', 'the', 'last', 'one', 'to', 'leave', 'for', 'home', 'that', 'evening,', 'there', 'remained', 'only', 'a', 'couple', 'of', 'workers', 'in', 'the', 'light', 'of', 'a', 'single', 'bulb', 'in', 'the', 'dispatch', 'he', 'heard', 'a', 'sigh', 'from', 'behind', 'a', 'door', 'which', 'he', 'had', 'himself', 'never', 'opened', 'but', 'which', 'he', 'had', 'always', 'thought', 'just', 'led', 'into', 'a', 'junk', 'room.', 'He', 'stood', 'in', 'amazement', 'and', 'listened', 'again', 'to', 'establish', 'whether', 'he', 'might', 'not', 'be', 'mistaken'], False: ['stairway\u2014he', 'department\u2014when']}\n\n######################################################\n\nprint(groupby_isdecimal(\n\n    seq=text, continue_on_exceptions=True, withindex=False, withvalue=True\n\n))\n\n# output: {False: ['One', 'evening,', 'a', 'few', 'days', 'later,', 'K.', 'was', 'walking', 'along', 'one', 'of', 'the', 'corridors', 'that', 'separated', 'his', 'office', 'from', 'the', 'main', 'stairway\u2014he', 'was', 'nearly', 'the', 'last', 'one', 'to', 'leave', 'for', 'home', 'that', 'evening,', 'there', 'remained', 'only', 'a', 'couple', 'of', 'workers', 'in', 'the', 'light', 'of', 'a', 'single', 'bulb', 'in', 'the', 'dispatch', 'department\u2014when', 'he', 'heard', 'a', 'sigh', 'from', 'behind', 'a', 'door', 'which', 'he', 'had', 'himself', 'never', 'opened', 'but', 'which', 'he', 'had', 'always', 'thought', 'just', 'led', 'into', 'a', 'junk', 'room.', 'He', 'stood', 'in', 'amazement', 'and', 'listened', 'again', 'to', 'establish', 'whether', 'he', 'might', 'not', 'be', 'mistaken']}\n\n######################################################\n\nprint(groupby_isdigit(\n\n    seq=text, continue_on_exceptions=True, withindex=False, withvalue=True\n\n))\n\n# output: {False: ['One', 'evening,', 'a', 'few', 'days', 'later,', 'K.', 'was', 'walking', 'along', 'one', 'of', 'the', 'corridors', 'that', 'separated', 'his', 'office', 'from', 'the', 'main', 'stairway\u2014he', 'was', 'nearly', 'the', 'last', 'one', 'to', 'leave', 'for', 'home', 'that', 'evening,', 'there', 'remained', 'only', 'a', 'couple', 'of', 'workers', 'in', 'the', 'light', 'of', 'a', 'single', 'bulb', 'in', 'the', 'dispatch', 'department\u2014when', 'he', 'heard', 'a', 'sigh', 'from', 'behind', 'a', 'door', 'which', 'he', 'had', 'himself', 'never', 'opened', 'but', 'which', 'he', 'had', 'always', 'thought', 'just', 'led', 'into', 'a', 'junk', 'room.', 'He', 'stood', 'in', 'amazement', 'and', 'listened', 'again', 'to', 'establish', 'whether', 'he', 'might', 'not', 'be', 'mistaken']}\n\n######################################################\n\nprint(groupby_isidentifier(\n\n    seq=text, continue_on_exceptions=True, withindex=False, withvalue=True\n\n))\n\n# output: {True: ['One', 'a', 'few', 'days', 'was', 'walking', 'along', 'one', 'of', 'the', 'corridors', 'that', 'separated', 'his', 'office', 'from', 'the', 'main', 'was', 'nearly', 'the', 'last', 'one', 'to', 'leave', 'for', 'home', 'that', 'there', 'remained', 'only', 'a', 'couple', 'of', 'workers', 'in', 'the', 'light', 'of', 'a', 'single', 'bulb', 'in', 'the', 'dispatch', 'he', 'heard', 'a', 'sigh', 'from', 'behind', 'a', 'door', 'which', 'he', 'had', 'himself', 'never', 'opened', 'but', 'which', 'he', 'had', 'always', 'thought', 'just', 'led', 'into', 'a', 'junk', 'He', 'stood', 'in', 'amazement', 'and', 'listened', 'again', 'to', 'establish', 'whether', 'he', 'might', 'not', 'be', 'mistaken'], False: ['evening,', 'later,', 'K.', 'stairway\u2014he', 'evening,', 'department\u2014when', 'room.']}\n\n######################################################\n\nprint(groupby_islower(\n\n    seq=text, continue_on_exceptions=True, withindex=False, withvalue=True\n\n))\n\n# output: {False: ['One', 'K.', 'He'], True: ['evening,', 'a', 'few', 'days', 'later,', 'was', 'walking', 'along', 'one', 'of', 'the', 'corridors', 'that', 'separated', 'his', 'office', 'from', 'the', 'main', 'stairway\u2014he', 'was', 'nearly', 'the', 'last', 'one', 'to', 'leave', 'for', 'home', 'that', 'evening,', 'there', 'remained', 'only', 'a', 'couple', 'of', 'workers', 'in', 'the', 'light', 'of', 'a', 'single', 'bulb', 'in', 'the', 'dispatch', 'department\u2014when', 'he', 'heard', 'a', 'sigh', 'from', 'behind', 'a', 'door', 'which', 'he', 'had', 'himself', 'never', 'opened', 'but', 'which', 'he', 'had', 'always', 'thought', 'just', 'led', 'into', 'a', 'junk', 'room.', 'stood', 'in', 'amazement', 'and', 'listened', 'again', 'to', 'establish', 'whether', 'he', 'might', 'not', 'be', 'mistaken']}\n\n######################################################\n\nprint(groupby_isnumeric(\n\n    seq=text, continue_on_exceptions=True, withindex=False, withvalue=True\n\n))\n\n# output: {False: ['One', 'evening,', 'a', 'few', 'days', 'later,', 'K.', 'was', 'walking', 'along', 'one', 'of', 'the', 'corridors', 'that', 'separated', 'his', 'office', 'from', 'the', 'main', 'stairway\u2014he', 'was', 'nearly', 'the', 'last', 'one', 'to', 'leave', 'for', 'home', 'that', 'evening,', 'there', 'remained', 'only', 'a', 'couple', 'of', 'workers', 'in', 'the', 'light', 'of', 'a', 'single', 'bulb', 'in', 'the', 'dispatch', 'department\u2014when', 'he', 'heard', 'a', 'sigh', 'from', 'behind', 'a', 'door', 'which', 'he', 'had', 'himself', 'never', 'opened', 'but', 'which', 'he', 'had', 'always', 'thought', 'just', 'led', 'into', 'a', 'junk', 'room.', 'He', 'stood', 'in', 'amazement', 'and', 'listened', 'again', 'to', 'establish', 'whether', 'he', 'might', 'not', 'be', 'mistaken']}\n\n######################################################\n\nprint(groupby_isprintable(\n\n    seq=text, continue_on_exceptions=True, withindex=False, withvalue=True\n\n))\n\n# output: {True: ['One', 'evening,', 'a', 'few', 'days', 'later,', 'K.', 'was', 'walking', 'along', 'one', 'of', 'the', 'corridors', 'that', 'separated', 'his', 'office', 'from', 'the', 'main', 'stairway\u2014he', 'was', 'nearly', 'the', 'last', 'one', 'to', 'leave', 'for', 'home', 'that', 'evening,', 'there', 'remained', 'only', 'a', 'couple', 'of', 'workers', 'in', 'the', 'light', 'of', 'a', 'single', 'bulb', 'in', 'the', 'dispatch', 'department\u2014when', 'he', 'heard', 'a', 'sigh', 'from', 'behind', 'a', 'door', 'which', 'he', 'had', 'himself', 'never', 'opened', 'but', 'which', 'he', 'had', 'always', 'thought', 'just', 'led', 'into', 'a', 'junk', 'room.', 'He', 'stood', 'in', 'amazement', 'and', 'listened', 'again', 'to', 'establish', 'whether', 'he', 'might', 'not', 'be', 'mistaken']}\n\n######################################################\n\nprint(groupby_isspace(\n\n    seq=text, continue_on_exceptions=True, withindex=False, withvalue=True\n\n))\n\n# output: {False: ['One', 'evening,', 'a', 'few', 'days', 'later,', 'K.', 'was', 'walking', 'along', 'one', 'of', 'the', 'corridors', 'that', 'separated', 'his', 'office', 'from', 'the', 'main', 'stairway\u2014he', 'was', 'nearly', 'the', 'last', 'one', 'to', 'leave', 'for', 'home', 'that', 'evening,', 'there', 'remained', 'only', 'a', 'couple', 'of', 'workers', 'in', 'the', 'light', 'of', 'a', 'single', 'bulb', 'in', 'the', 'dispatch', 'department\u2014when', 'he', 'heard', 'a', 'sigh', 'from', 'behind', 'a', 'door', 'which', 'he', 'had', 'himself', 'never', 'opened', 'but', 'which', 'he', 'had', 'always', 'thought', 'just', 'led', 'into', 'a', 'junk', 'room.', 'He', 'stood', 'in', 'amazement', 'and', 'listened', 'again', 'to', 'establish', 'whether', 'he', 'might', 'not', 'be', 'mistaken']}\n\n######################################################\n\nprint(groupby_istitle(\n\n    seq=text, continue_on_exceptions=True, withindex=False, withvalue=True\n\n))\n\n# output: {True: ['One', 'K.', 'He'], False: ['evening,', 'a', 'few', 'days', 'later,', 'was', 'walking', 'along', 'one', 'of', 'the', 'corridors', 'that', 'separated', 'his', 'office', 'from', 'the', 'main', 'stairway\u2014he', 'was', 'nearly', 'the', 'last', 'one', 'to', 'leave', 'for', 'home', 'that', 'evening,', 'there', 'remained', 'only', 'a', 'couple', 'of', 'workers', 'in', 'the', 'light', 'of', 'a', 'single', 'bulb', 'in', 'the', 'dispatch', 'department\u2014when', 'he', 'heard', 'a', 'sigh', 'from', 'behind', 'a', 'door', 'which', 'he', 'had', 'himself', 'never', 'opened', 'but', 'which', 'he', 'had', 'always', 'thought', 'just', 'led', 'into', 'a', 'junk', 'room.', 'stood', 'in', 'amazement', 'and', 'listened', 'again', 'to', 'establish', 'whether', 'he', 'might', 'not', 'be', 'mistaken']}\n\n######################################################\n\nprint(groupby_isupper(\n\n    seq=text, continue_on_exceptions=True, withindex=False, withvalue=True\n\n))\n\n# output: {False: ['One', 'evening,', 'a', 'few', 'days', 'later,', 'was', 'walking', 'along', 'one', 'of', 'the', 'corridors', 'that', 'separated', 'his', 'office', 'from', 'the', 'main', 'stairway\u2014he', 'was', 'nearly', 'the', 'last', 'one', 'to', 'leave', 'for', 'home', 'that', 'evening,', 'there', 'remained', 'only', 'a', 'couple', 'of', 'workers', 'in', 'the', 'light', 'of', 'a', 'single', 'bulb', 'in', 'the', 'dispatch', 'department\u2014when', 'he', 'heard', 'a', 'sigh', 'from', 'behind', 'a', 'door', 'which', 'he', 'had', 'himself', 'never', 'opened', 'but', 'which', 'he', 'had', 'always', 'thought', 'just', 'led', 'into', 'a', 'junk', 'room.', 'He', 'stood', 'in', 'amazement', 'and', 'listened', 'again', 'to', 'establish', 'whether', 'he', 'might', 'not', 'be', 'mistaken'], True: ['K.']}\n\n######################################################\n\nprint(groupby_isin(value='1', seq=['1', '11', '2', 1,2,3,54,2], continue_on_exceptions=True, withindex=False, withvalue=True\n\n))\n\n# output: {True: ['1', '11'], False: ['2'], \"EXCEPTION: argument of type 'int' is not iterable\": [1, 2, 3, 54, 2]}\n\n######################################################\n\nimport random\n\nprint(groupby_rectangle_intersects(\n\n    rectangle=(0, 0, 100, 100),\n\n    seq=[\n\n        (\n\n            g := random.randrange(1, 200),\n\n            f := random.randrange(1, 200),\n\n            g + 100,\n\n            f + 100,\n\n        )\n\n        for _ in range(10)\n\n    ],\n\n    continue_on_exceptions=True,\n\n    withindex=True,\n\n))\n\n# output: {False: [(0, (88, 157, 188, 257)), (1, (176, 63, 276, 163)), (2, (38, 102, 138, 202)), (4, (159, 145, 259, 245)), (5, (84, 199, 184, 299)), (6, (6, 160, 106, 260)), (7, (101, 133, 201, 233)), (9, (188, 148, 288, 248))], True: [(3, (27, 68, 127, 168)), (8, (2, 58, 102, 158))]}\n\n######################################################\n\nimport pandas as pd\n\nimport math\n\nimport numpy as np\n\nprint(groupby_isna(\n\n    seq=[pd.NA, np.nan, None, math.nan, 3,54,3,(22,34,412), {323,31}, [3312,3]],\n\n    emptyiters = False,\n\n    nastrings = False,\n\n    emptystrings = False,\n\n    emptybytes = False,\n\n    continue_on_exceptions=True,\n\n    withindex=False,\n\n    withvalue=True,\n\n))\n\n# output: {True: [<NA>, nan, None, nan], False: [3, 54, 3, (22, 34, 412), {323, 31}, [3312, 3]]}\n\n######################################################\n\nimport pandas as pd\n\nimport math\n\nimport numpy as np\n\nprint(groupby_isiter(\n\n    seq=[pd.NA, np.nan, None, math.nan, 3, 54, 3, (22, 34, 412), {323, 31}, [3312, 3]],\n\n    continue_on_exceptions=True,\n\n    withindex=False,\n\n    withvalue=True,\n\n))\n\n# output: {False: [<NA>, nan, None, nan, 3, 54, 3], True: [(22, 34, 412), {323, 31}, [3312, 3]]}\n\n######################################################\n\nimport os\n\nprint(groupby_file_extension(\n\n    seq=os.listdir(r'F:\\gitrep\\screenshots'), continue_on_exceptions=True, withindex=False, withvalue=True\n\n))\n\n# output: {'': ['.git', '.gitignore', 'color', 'debugdf', 'enumeratefiles', 'LICENSE', 'sortfiles'], '.png': ['144.png', '146.png', '2022-12-27 03_40_27-.png', '2022-12-27 03_49_27-.png', '2022-12-27 04_01_57-.png', '2022-12-27 04_02_09-.png', '2023-01-01 09_48_27-single_elements.png', 'add_methods.png', 'allcolors.png', 'asciiart.png', 'bluestacksauto.png', 'buttonsearch.png', 'collage.png', 'colorfind1.png', 'colorfind1xxx.png', 'colorfind2.png', 'colorfind3.png', 'colorfind4.png', 'cv2_putTrueTypeText_000000.png', 'cv2_putTrueTypeText_000001.png', 'cv2_putTrueTypeText_000002.png', 'cv2_putTrueTypeText_000003.png', 'cv2_putTrueTypeText_000004.png', 'cv2_putTrueTypeText_000005.png', 'cv2_putTrueTypeText_000006.png', 'cv2_putTrueTypeText_000007.png', 'cv2_putTrueTypeText_000008.png', 'cv2_putTrueTypeText_000009.png', 'cv2_putTrueTypeText_000010.png', 'cv2_putTrueTypeText_000011.png', 'cv2_putTrueTypeText_000012.png', 'cv2_putTrueTypeText_000013.png', 'cv2_putTrueTypeText_000014.png', 'cv2_putTrueTypeText_000015.png', 'cv2_putTrueTypeText_000017.png', 'dfresults.png', 'df_act01.png', 'df_act01_0.png', 'df_act02.png', 'df_act02_0.png', 'df_screen01.png', 'df_screen02.png', 'diff.png', 'findshapes_1.png', 'findshapes_2.png', 'findsquare.png', 'fromjsonorg.png', 'from_nested_dict.png', 'generateimgs.png', 'horizontal.png', 'imagediffsquare.png', 'jsonstring.png', 'json_from_file.png', 'json_from_file_sp.png', 'json_url.png', 'lines.png', 'merg1.png', 'merg2.png', 'merg3.png', 'merg4.png', 'merg5.png', 'merg6.png', 'merg7.png', 'noformat.png', 'norm.png', 'pandasconsoleplott.png', 'pandsnesteddicthtml.png', 'papag_00000000.png', 'papag_00000001.png', 'papag_00000002.png', 'papag_00000003.png', 'papag_00000004.png', 'papag_00000005.png', 'papag_00000006.png', 'papag_00000007.png', 'papag_00000008.png', 'papag_00000009.png', 'pic1.png', 'pic2.png', 'pic3.png', 'pic4.png', 'pic5.png', 'PROXY.png', 'randomscreenshots.png', 'rect1.png', 'rect2.png', 'resultsscreenshots.png', 'rotate1.png', 'rotate2.png', 'screencap1.png', 'screencap2.png', 'screencap3.png', 'screencap4.png', 'screenshotpandasseries.png', 'screenshotpandastable.png', 'seleniumkeys.png', 'sendevent_key.png', 'sendevent_key_video.png', 'sift.png', 'splitted0.png', 'splitted1.png', 'templatematching1.png', 'templatematching2.png', 'templatematching3.png', 'templatematching4.png', 'templatematching5.png', 'templatematching6.png', 'templatematching7.png', 'tensorflowscreen.png', 'tesseractscreen.png', 'testwholescreenshot.png', 'timemea.png', 'vc01.png', 'vc01_0.png', 'vertical.png', 'zoompics_0000001.png', 'zoompics_0000002.png', 'zoompics_0000003.png', 'zoompics_0000004.png', 'zoompics_0000005.png', 'zoompics_0000006.png', 'zoompics_0000007.png', 'zoompics_0000008.png'], '.css': ['df_style.css'], '.html': ['fromjsonorg.html', 'from_nested_dict.html', 'jsonstring.html', 'json_from_file.html', 'json_url.html', 'myhtml.html'], '.jpeg': ['splitted1.jpeg'], '.mp4': ['tesseractscreen.mp4']}\n\n######################################################\n\nfrom a_cv_imwrite_imread_plus import open_image_in_cv\n\nprint(groupby_color_qty_in_region(\n\n    im=open_image_in_cv(\n\n        \"https://github.com/hansalemaos/screenshots/raw/main/colorfind1.png\"\n\n    ),\n\n    colors=[(0, 0, 0)],\n\n    startx=None,\n\n    starty=None,\n\n    stopx=None,\n\n    stopy=None,\n\n    rect_w=10,\n\n    rect_h=10,\n\n    continue_on_exceptions=True,\n\n    withindex=False,\n\n    withvalue=True,\n\n))\n\n# output: {100: [(0, 0, 10, 10), (0, 10, 10, 20), (0, 20, 10, 30), (0, 30, 10, 40), (0, 40, 10, 50), (0, 50, 10, 60), (0, 60, 10, 70), (0, 70, 10, 80), (0, 80, 10, 90), (0, 90, 10, 100), (0, 100, 10, 110), (0, 110, 10, 120), (0, 120, 10, 130), (0, 130, 10, 140), (0, 140, 10, 150), (0, 150, 10, 160), (0, 160, 10, 170), (0, 170, 10, 180), (0, 180, 10, 190), (0, 190, 10, 200), (10, 0, 20, 10), (10, 10, 20, 20), (10, 20, 20, 30), (10, 30, 20, 40), (10, 40, 20, 50), (10, 50, 20, 60), (10, 60, 20, 70), (10, 70, 20, 80), (10, 80, 20, 90), (10, 90, 20, 100), (10, 100, 20, 110), (10, 110, 20, 120), (10, 120, 20, 130), (10, 130, 20, 140), (10, 140, 20, 150), (10, 150, 20, 160), (10, 160, 20, 170), (10, 170, 20, 180), (10, 180, 20, 190), (10, 190, 20, 200), (20, 0, 30, 10), (20, 10, 30, 20), (20, 20, 30, 30), (20, 30, 30, 40), (20, 40, 30, 50), (20, 50, 30, 60), (20, 60, 30, 70), (20, 70, 30, 80), (20, 80, 30, 90), (20, 90, 30, 100), (20, 100, 30, 110), (20, 110, 30, 120), (20, 120, 30, 130), (20, 130, 30, 140), (20, 140, 30, 150), (20, 150, 30, 160), (20, 160, 30, 170), (20, 170, 30, 180), (20, 180, 30, 190), (20, 190, 30, 200), (30, 0, 40, 10), (30, 10, 40, 20), (30, 20, 40, 30), (30, 30, 40, 40), (30, 40, 40, 50), (30, 50, 40, 60), (30, 60, 40, 70), (30, 130, 40, 140), (30, 140, 40, 150), (30, 150, 40, 160), (30, 160, 40, 170), (30, 170, 40, 180), (30, 180, 40, 190), (30, 190, 40, 200), (40, 0, 50, 10), (40, 10, 50, 20), (40, 20, 50, 30), (40, 30, 50, 40), (40, 40, 50, 50), (40, 50, 50, 60), (40, 140, 50, 150), (40, 150, 50, 160), (40, 160, 50, 170), (40, 170, 50, 180), (40, 180, 50, 190), (40, 190, 50, 200), (50, 0, 60, 10), (50, 10, 60, 20), (50, 20, 60, 30), (50, 30, 60, 40), (50, 40, 60, 50), (50, 50, 60, 60), (50, 140, 60, 150), (50, 150, 60, 160), (50, 160, 60, 170), (50, 170, 60, 180), (50, 180, 60, 190), (50, 190, 60, 200), (60, 0, 70, 10), (60, 10, 70, 20), (60, 20, 70, 30), (60, 160, 70, 170), (60, 170, 70, 180), (60, 180, 70, 190), (60, 190, 70, 200), (70, 0, 80, 10), (70, 10, 80, 20), (70, 20, 80, 30), (70, 170, 80, 180), (70, 180, 80, 190), (70, 190, 80, 200), (80, 0, 90, 10), (80, 10, 90, 20), (80, 20, 90, 30), (80, 170, 90, 180), (80, 180, 90, 190), (80, 190, 90, 200), (90, 0, 100, 10), (90, 10, 100, 20), (90, 20, 100, 30), (90, 170, 100, 180), (90, 180, 100, 190), (90, 190, 100, 200), (100, 0, 110, 10), (100, 10, 110, 20), (100, 20, 110, 30), (100, 170, 110, 180), (100, 180, 110, 190), (100, 190, 110, 200), (110, 0, 120, 10), (110, 10, 120, 20), (110, 20, 120, 30), (110, 170, 120, 180), (110, 180, 120, 190), (110, 190, 120, 200), (120, 0, 130, 10), (120, 10, 130, 20), (120, 20, 130, 30), (120, 170, 130, 180), (120, 180, 130, 190), (120, 190, 130, 200), (130, 0, 140, 10), (130, 10, 140, 20), (130, 20, 140, 30), (130, 30, 140, 40), (130, 160, 140, 170), (130, 170, 140, 180), (130, 180, 140, 190), (130, 190, 140, 200), (140, 0, 150, 10), (140, 10, 150, 20), (140, 20, 150, 30), (140, 30, 150, 40), (140, 40, 150, 50), (140, 50, 150, 60), (140, 140, 150, 150), (140, 150, 150, 160), (140, 160, 150, 170), (140, 170, 150, 180), (140, 180, 150, 190), (140, 190, 150, 200), (150, 0, 160, 10), (150, 10, 160, 20), (150, 20, 160, 30), (150, 30, 160, 40), (150, 40, 160, 50), (150, 50, 160, 60), (150, 140, 160, 150), (150, 150, 160, 160), (150, 160, 160, 170), (150, 170, 160, 180), (150, 180, 160, 190), (150, 190, 160, 200), (160, 0, 170, 10), (160, 10, 170, 20), (160, 20, 170, 30), (160, 30, 170, 40), (160, 40, 170, 50), (160, 50, 170, 60), (160, 60, 170, 70), (160, 130, 170, 140), (160, 140, 170, 150), (160, 150, 170, 160), (160, 160, 170, 170), (160, 170, 170, 180), (160, 180, 170, 190), (160, 190, 170, 200), (170, 0, 180, 10), (170, 10, 180, 20), (170, 20, 180, 30), (170, 30, 180, 40), (170, 40, 180, 50), (170, 50, 180, 60), (170, 60, 180, 70), (170, 70, 180, 80), (170, 80, 180, 90), (170, 90, 180, 100), (170, 100, 180, 110), (170, 110, 180, 120), (170, 120, 180, 130), (170, 130, 180, 140), (170, 140, 180, 150), (170, 150, 180, 160), (170, 160, 180, 170), (170, 170, 180, 180), (170, 180, 180, 190), (170, 190, 180, 200), (180, 0, 190, 10), (180, 10, 190, 20), (180, 20, 190, 30), (180, 30, 190, 40), (180, 40, 190, 50), (180, 50, 190, 60), (180, 60, 190, 70), (180, 70, 190, 80), (180, 80, 190, 90), (180, 90, 190, 100), (180, 100, 190, 110), (180, 110, 190, 120), (180, 120, 190, 130), (180, 130, 190, 140), (180, 140, 190, 150), (180, 150, 190, 160), (180, 160, 190, 170), (180, 170, 190, 180), (180, 180, 190, 190), (180, 190, 190, 200), (190, 0, 200, 10), (190, 10, 200, 20), (190, 20, 200, 30), (190, 30, 200, 40), (190, 40, 200, 50), (190, 50, 200, 60), (190, 60, 200, 70), (190, 70, 200, 80), (190, 80, 200, 90), (190, 90, 200, 100), (190, 100, 200, 110), (190, 110, 200, 120), (190, 120, 200, 130), (190, 130, 200, 140), (190, 140, 200, 150), (190, 150, 200, 160), (190, 160, 200, 170), (190, 170, 200, 180), (190, 180, 200, 190), (190, 190, 200, 200)], 65: [(30, 70, 40, 80)], 27: [(30, 80, 40, 90)], 11: [(30, 90, 40, 100)], 13: [(30, 100, 40, 110)], 30: [(30, 110, 40, 120), (60, 110, 70, 120), (60, 120, 70, 130), (100, 130, 110, 140), (110, 130, 120, 140), (120, 90, 130, 100), (120, 130, 130, 140), (130, 70, 140, 80), (130, 80, 140, 90)], 71: [(30, 120, 40, 130)], 76: [(40, 60, 50, 70), (130, 40, 140, 50), (160, 120, 170, 130)], 0: [(40, 70, 50, 80), (40, 80, 50, 90), (40, 90, 50, 100), (40, 100, 50, 110), (40, 110, 50, 120), (50, 70, 60, 80), (50, 80, 60, 90), (50, 90, 60, 100), (50, 100, 60, 110), (50, 110, 60, 120), (50, 120, 60, 130), (60, 70, 70, 80), (60, 80, 70, 90), (60, 90, 70, 100), (70, 40, 80, 50), (70, 50, 80, 60), (70, 70, 80, 80), (70, 80, 80, 90), (70, 110, 80, 120), (70, 120, 80, 130), (70, 130, 80, 140), (70, 140, 80, 150), (70, 150, 80, 160), (80, 40, 90, 50), (80, 50, 90, 60), (80, 70, 90, 80), (80, 80, 90, 90), (80, 110, 90, 120), (80, 120, 90, 130), (80, 130, 90, 140), (80, 140, 90, 150), (80, 150, 90, 160), (90, 40, 100, 50), (90, 50, 100, 60), (90, 70, 100, 80), (90, 80, 100, 90), (90, 110, 100, 120), (90, 120, 100, 130), (90, 130, 100, 140), (90, 140, 100, 150), (90, 150, 100, 160), (100, 40, 110, 50), (100, 50, 110, 60), (100, 60, 110, 70), (100, 70, 110, 80), (100, 80, 110, 90), (100, 110, 110, 120), (100, 120, 110, 130), (100, 140, 110, 150), (100, 150, 110, 160), (110, 40, 120, 50), (110, 50, 120, 60), (110, 60, 120, 70), (110, 70, 120, 80), (110, 80, 120, 90), (110, 110, 120, 120), (110, 120, 120, 130), (110, 140, 120, 150), (110, 150, 120, 160), (120, 40, 130, 50), (120, 50, 130, 60), (120, 60, 130, 70), (120, 70, 130, 80), (120, 80, 130, 90), (120, 100, 130, 110), (120, 110, 130, 120), (120, 120, 130, 130), (120, 140, 130, 150), (130, 100, 140, 110), (130, 110, 140, 120), (130, 120, 140, 130), (140, 70, 150, 80), (140, 80, 150, 90), (140, 90, 150, 100), (140, 100, 150, 110), (140, 110, 150, 120), (140, 120, 150, 130), (150, 70, 160, 80), (150, 80, 160, 90), (150, 90, 160, 100), (150, 100, 160, 110), (150, 110, 160, 120)], 1: [(40, 120, 50, 130), (120, 150, 130, 160), (150, 120, 160, 130)], 83: [(40, 130, 50, 140)], 60: [(50, 60, 60, 70), (60, 50, 70, 60), (60, 140, 70, 150), (140, 60, 150, 70)], 70: [(50, 130, 60, 140), (130, 50, 140, 60), (130, 140, 140, 150), (140, 130, 150, 140)], 97: [(60, 30, 70, 40)], 66: [(60, 40, 70, 50)], 52: [(60, 60, 70, 70)], 16: [(60, 100, 70, 110), (80, 30, 90, 40)], 51: [(60, 130, 70, 140)], 78: [(60, 150, 70, 160)], 43: [(70, 30, 80, 40)], 40: [(70, 60, 80, 70), (80, 60, 90, 70)], 6: [(70, 90, 80, 100)], 26: [(70, 100, 80, 110)], 72: [(70, 160, 80, 170)], 20: [(80, 90, 90, 100), (90, 90, 100, 100), (100, 90, 110, 100), (110, 90, 120, 100)], 10: [(80, 100, 90, 110), (90, 30, 100, 40), (90, 100, 100, 110), (100, 30, 110, 40), (100, 100, 110, 110)], 32: [(80, 160, 90, 170)], 36: [(90, 60, 100, 70)], 14: [(90, 160, 100, 170), (160, 90, 170, 100), (160, 100, 170, 110)], 15: [(100, 160, 110, 170)], 17: [(110, 30, 120, 40)], 9: [(110, 100, 120, 110), (130, 90, 140, 100)], 33: [(110, 160, 120, 170), (160, 110, 170, 120)], 54: [(120, 30, 130, 40), (130, 60, 140, 70)], 73: [(120, 160, 130, 170)], 58: [(130, 130, 140, 140)], 81: [(130, 150, 140, 160), (150, 130, 160, 140)], 69: [(150, 60, 160, 70)], 64: [(160, 70, 170, 80)], 31: [(160, 80, 170, 90)]}\n\n######################################################\n\nprint(groupby_even_odd(\n\n    seq=[1, 2, 3, 45, 56, 6, 32, 12], continue_on_exceptions=True, withindex=False\n\n))\n\n# output: {'odd': [1, 3, 45], 'even': [2, 56, 6, 32, 12]}\n\n######################################################\n\nprint(\n\n    groupby_files_folder_link(\n\n        seq=[\n\n            os.path.join(r\"F:\\gitrep\\screenshots\", x)\n\n            for x in os.listdir(r\"F:\\gitrep\\screenshots\")\n\n        ],\n\n        continue_on_exceptions=True,\n\n        withindex=False,\n\n        withvalue=True,\n\n    )\n\n)\n\n# output: {'folder': ['F:\\\\gitrep\\\\screenshots\\\\.git', 'F:\\\\gitrep\\\\screenshots\\\\color', 'F:\\\\gitrep\\\\screenshots\\\\debugdf', 'F:\\\\gitrep\\\\screenshots\\\\enumeratefiles', 'F:\\\\gitrep\\\\screenshots\\\\sortfiles'], 'file': ['F:\\\\gitrep\\\\screenshots\\\\.gitignore', 'F:\\\\gitrep\\\\screenshots\\\\144.png', 'F:\\\\gitrep\\\\screenshots\\\\146.png', 'F:\\\\gitrep\\\\screenshots\\\\2022-12-27 03_40_27-.png', 'F:\\\\gitrep\\\\screenshots\\\\2022-12-27 03_49_27-.png', 'F:\\\\gitrep\\\\screenshots\\\\2022-12-27 04_01_57-.png', 'F:\\\\gitrep\\\\screenshots\\\\2022-12-27 04_02_09-.png', 'F:\\\\gitrep\\\\screenshots\\\\2023-01-01 09_48_27-single_elements.png', 'F:\\\\gitrep\\\\screenshots\\\\add_methods.png', 'F:\\\\gitrep\\\\screenshots\\\\allcolors.png', 'F:\\\\gitrep\\\\screenshots\\\\asciiart.png', 'F:\\\\gitrep\\\\screenshots\\\\bluestacksauto.png', 'F:\\\\gitrep\\\\screenshots\\\\buttonsearch.png', 'F:\\\\gitrep\\\\screenshots\\\\collage.png', 'F:\\\\gitrep\\\\screenshots\\\\colorfind1.png', 'F:\\\\gitrep\\\\screenshots\\\\colorfind1xxx.png', 'F:\\\\gitrep\\\\screenshots\\\\colorfind2.png', 'F:\\\\gitrep\\\\screenshots\\\\colorfind3.png', 'F:\\\\gitrep\\\\screenshots\\\\colorfind4.png', 'F:\\\\gitrep\\\\screenshots\\\\cv2_putTrueTypeText_000000.png', 'F:\\\\gitrep\\\\screenshots\\\\cv2_putTrueTypeText_000001.png', 'F:\\\\gitrep\\\\screenshots\\\\cv2_putTrueTypeText_000002.png', 'F:\\\\gitrep\\\\screenshots\\\\cv2_putTrueTypeText_000003.png', 'F:\\\\gitrep\\\\screenshots\\\\cv2_putTrueTypeText_000004.png', 'F:\\\\gitrep\\\\screenshots\\\\cv2_putTrueTypeText_000005.png', 'F:\\\\gitrep\\\\screenshots\\\\cv2_putTrueTypeText_000006.png', 'F:\\\\gitrep\\\\screenshots\\\\cv2_putTrueTypeText_000007.png', 'F:\\\\gitrep\\\\screenshots\\\\cv2_putTrueTypeText_000008.png', 'F:\\\\gitrep\\\\screenshots\\\\cv2_putTrueTypeText_000009.png', 'F:\\\\gitrep\\\\screenshots\\\\cv2_putTrueTypeText_000010.png', 'F:\\\\gitrep\\\\screenshots\\\\cv2_putTrueTypeText_000011.png', 'F:\\\\gitrep\\\\screenshots\\\\cv2_putTrueTypeText_000012.png', 'F:\\\\gitrep\\\\screenshots\\\\cv2_putTrueTypeText_000013.png', 'F:\\\\gitrep\\\\screenshots\\\\cv2_putTrueTypeText_000014.png', 'F:\\\\gitrep\\\\screenshots\\\\cv2_putTrueTypeText_000015.png', 'F:\\\\gitrep\\\\screenshots\\\\cv2_putTrueTypeText_000017.png', 'F:\\\\gitrep\\\\screenshots\\\\dfresults.png', 'F:\\\\gitrep\\\\screenshots\\\\df_act01.png', 'F:\\\\gitrep\\\\screenshots\\\\df_act01_0.png', 'F:\\\\gitrep\\\\screenshots\\\\df_act02.png', 'F:\\\\gitrep\\\\screenshots\\\\df_act02_0.png', 'F:\\\\gitrep\\\\screenshots\\\\df_screen01.png', 'F:\\\\gitrep\\\\screenshots\\\\df_screen02.png', 'F:\\\\gitrep\\\\screenshots\\\\df_style.css', 'F:\\\\gitrep\\\\screenshots\\\\diff.png', 'F:\\\\gitrep\\\\screenshots\\\\findshapes_1.png', 'F:\\\\gitrep\\\\screenshots\\\\findshapes_2.png', 'F:\\\\gitrep\\\\screenshots\\\\findsquare.png', 'F:\\\\gitrep\\\\screenshots\\\\fromjsonorg.html', 'F:\\\\gitrep\\\\screenshots\\\\fromjsonorg.png', 'F:\\\\gitrep\\\\screenshots\\\\from_nested_dict.html', 'F:\\\\gitrep\\\\screenshots\\\\from_nested_dict.png', 'F:\\\\gitrep\\\\screenshots\\\\generateimgs.png', 'F:\\\\gitrep\\\\screenshots\\\\horizontal.png', 'F:\\\\gitrep\\\\screenshots\\\\imagediffsquare.png', 'F:\\\\gitrep\\\\screenshots\\\\jsonstring.html', 'F:\\\\gitrep\\\\screenshots\\\\jsonstring.png', 'F:\\\\gitrep\\\\screenshots\\\\json_from_file.html', 'F:\\\\gitrep\\\\screenshots\\\\json_from_file.png', 'F:\\\\gitrep\\\\screenshots\\\\json_from_file_sp.png', 'F:\\\\gitrep\\\\screenshots\\\\json_url.html', 'F:\\\\gitrep\\\\screenshots\\\\json_url.png', 'F:\\\\gitrep\\\\screenshots\\\\LICENSE', 'F:\\\\gitrep\\\\screenshots\\\\lines.png', 'F:\\\\gitrep\\\\screenshots\\\\merg1.png', 'F:\\\\gitrep\\\\screenshots\\\\merg2.png', 'F:\\\\gitrep\\\\screenshots\\\\merg3.png', 'F:\\\\gitrep\\\\screenshots\\\\merg4.png', 'F:\\\\gitrep\\\\screenshots\\\\merg5.png', 'F:\\\\gitrep\\\\screenshots\\\\merg6.png', 'F:\\\\gitrep\\\\screenshots\\\\merg7.png', 'F:\\\\gitrep\\\\screenshots\\\\myhtml.html', 'F:\\\\gitrep\\\\screenshots\\\\noformat.png', 'F:\\\\gitrep\\\\screenshots\\\\norm.png', 'F:\\\\gitrep\\\\screenshots\\\\pandasconsoleplott.png', 'F:\\\\gitrep\\\\screenshots\\\\pandsnesteddicthtml.png', 'F:\\\\gitrep\\\\screenshots\\\\papag_00000000.png', 'F:\\\\gitrep\\\\screenshots\\\\papag_00000001.png', 'F:\\\\gitrep\\\\screenshots\\\\papag_00000002.png', 'F:\\\\gitrep\\\\screenshots\\\\papag_00000003.png', 'F:\\\\gitrep\\\\screenshots\\\\papag_00000004.png', 'F:\\\\gitrep\\\\screenshots\\\\papag_00000005.png', 'F:\\\\gitrep\\\\screenshots\\\\papag_00000006.png', 'F:\\\\gitrep\\\\screenshots\\\\papag_00000007.png', 'F:\\\\gitrep\\\\screenshots\\\\papag_00000008.png', 'F:\\\\gitrep\\\\screenshots\\\\papag_00000009.png', 'F:\\\\gitrep\\\\screenshots\\\\pic1.png', 'F:\\\\gitrep\\\\screenshots\\\\pic2.png', 'F:\\\\gitrep\\\\screenshots\\\\pic3.png', 'F:\\\\gitrep\\\\screenshots\\\\pic4.png', 'F:\\\\gitrep\\\\screenshots\\\\pic5.png', 'F:\\\\gitrep\\\\screenshots\\\\PROXY.png', 'F:\\\\gitrep\\\\screenshots\\\\randomscreenshots.png', 'F:\\\\gitrep\\\\screenshots\\\\rect1.png', 'F:\\\\gitrep\\\\screenshots\\\\rect2.png', 'F:\\\\gitrep\\\\screenshots\\\\resultsscreenshots.png', 'F:\\\\gitrep\\\\screenshots\\\\rotate1.png', 'F:\\\\gitrep\\\\screenshots\\\\rotate2.png', 'F:\\\\gitrep\\\\screenshots\\\\screencap1.png', 'F:\\\\gitrep\\\\screenshots\\\\screencap2.png', 'F:\\\\gitrep\\\\screenshots\\\\screencap3.png', 'F:\\\\gitrep\\\\screenshots\\\\screencap4.png', 'F:\\\\gitrep\\\\screenshots\\\\screenshotpandasseries.png', 'F:\\\\gitrep\\\\screenshots\\\\screenshotpandastable.png', 'F:\\\\gitrep\\\\screenshots\\\\seleniumkeys.png', 'F:\\\\gitrep\\\\screenshots\\\\sendevent_key.png', 'F:\\\\gitrep\\\\screenshots\\\\sendevent_key_video.png', 'F:\\\\gitrep\\\\screenshots\\\\sift.png', 'F:\\\\gitrep\\\\screenshots\\\\splitted0.png', 'F:\\\\gitrep\\\\screenshots\\\\splitted1.jpeg', 'F:\\\\gitrep\\\\screenshots\\\\splitted1.png', 'F:\\\\gitrep\\\\screenshots\\\\templatematching1.png', 'F:\\\\gitrep\\\\screenshots\\\\templatematching2.png', 'F:\\\\gitrep\\\\screenshots\\\\templatematching3.png', 'F:\\\\gitrep\\\\screenshots\\\\templatematching4.png', 'F:\\\\gitrep\\\\screenshots\\\\templatematching5.png', 'F:\\\\gitrep\\\\screenshots\\\\templatematching6.png', 'F:\\\\gitrep\\\\screenshots\\\\templatematching7.png', 'F:\\\\gitrep\\\\screenshots\\\\tensorflowscreen.png', 'F:\\\\gitrep\\\\screenshots\\\\tesseractscreen.mp4', 'F:\\\\gitrep\\\\screenshots\\\\tesseractscreen.png', 'F:\\\\gitrep\\\\screenshots\\\\testwholescreenshot.png', 'F:\\\\gitrep\\\\screenshots\\\\timemea.png', 'F:\\\\gitrep\\\\screenshots\\\\vc01.png', 'F:\\\\gitrep\\\\screenshots\\\\vc01_0.png', 'F:\\\\gitrep\\\\screenshots\\\\vertical.png', 'F:\\\\gitrep\\\\screenshots\\\\zoompics_0000001.png', 'F:\\\\gitrep\\\\screenshots\\\\zoompics_0000002.png', 'F:\\\\gitrep\\\\screenshots\\\\zoompics_0000003.png', 'F:\\\\gitrep\\\\screenshots\\\\zoompics_0000004.png', 'F:\\\\gitrep\\\\screenshots\\\\zoompics_0000005.png', 'F:\\\\gitrep\\\\screenshots\\\\zoompics_0000006.png', 'F:\\\\gitrep\\\\screenshots\\\\zoompics_0000007.png', 'F:\\\\gitrep\\\\screenshots\\\\zoompics_0000008.png']}\n\n######################################################\n\nimport pandas as pd\n\nimport math\n\nimport numpy as np\n\nprint(groupby_sys_size(seq=[pd.NA, np.nan, None, math.nan, 3,54,3,(22,34,412), {323,31}, [3312,3]], continue_on_exceptions=True, withindex=False))\n\n\n\n# output: {48: [<NA>], 24: [nan, nan], 16: [None], 28: [3, 54, 3], 64: [(22, 34, 412)], 216: [{323, 31}], 72: [[3312, 3]]}\n\n######################################################\n\nprint(groupby_first_item(\n\n    seq=[[1,2,34,], (1,32,4), (2,3,4,54), [2,3,3]], continue_on_exceptions=True, withindex=False\n\n))\n\n# output: {1: [[1, 2, 34], (1, 32, 4)], 2: [(2, 3, 4, 54), [2, 3, 3]]}\n\n######################################################\n\nprint(groupby_words_in_texts(\n\n    textlist=[\"autobahn\", \"computerproblem\", \"kind\", \"opa\", \"kind opa\"],\n\n    wordlist=[\"kind\", \"opa\"],\n\n    case_sen=False,\n\n    continue_on_exceptions=True,\n\n    withindex=False,\n\n    boundary_right=True,\n\n    boundary_left=True,\n\n))\n\n# output: {(): ['autobahn', 'computerproblem'], ('kind',): ['kind'], ('opa',): ['opa'], ('kind', 'opa'): ['kind opa']}\n\n######################################################\n\nprint(groupby_sum(\n\n    seq=[[1, 2, 2], [5], [2, 3], [4, 4, 4], [12, 0], [6, 6], [1, 2]],\n\n    continue_on_exceptions=True,\n\n    withindex=False,\n\n))\n\n# output: {5: [[1, 2, 2], [5], [2, 3]], 12: [[4, 4, 4], [12, 0], [6, 6]], 3: [[1, 2]]}\n\n######################################################\n\nprint(groupby_valid_url(\n\n    seq=[\"https://www.google.com\", \"google.com/\", 'bababa', 'http://baba.de'],\n\n    continue_on_exceptions=True,\n\n    withindex=False,\n\n    withvalue=True,\n\n))\n\n# output: {'valid': ['https://www.google.com', 'http://baba.de'], 'not_valid': ['google.com/', 'bababa']}\n\n######################################################\n\nprint(groupby_literal_eval_type(\n\n    seq=['11', 'bb', '\"bb\"'], continue_on_exceptions=True, withindex=False, withvalue=True\n\n))\n\n# output: {<class 'int'>: ['11'], 'EXCEPTION: malformed node or string: <ast.Name object at 0x0000000013A54340>': ['bb'], <class 'str'>: ['\"bb\"']}\n\n######################################################\n\nrint(groupby_decoding_result(bytes_=b'\\\\U0001D11E',mode='strict',\n\n     continue_on_exceptions=True, withindex=False, withvalue=True\n\n))\n\n# output:  {'\\\\U0001D11E': ['ascii',\n\n#                 'big5',\n\n#                 'big5hkscs',\n\n#                 'charmap',\n\n# \t\t\t\t ......\n\n#                 'palmos',\n\n#                 'ptcp154',\n\n#                 'shift_jis',\n\n#                 'tis_620',\n\n#                 'utf_7',\n\n#                 'utf_8',\n\n#                 'utf_8_sig'],\n\n# '\u00a5U0001D11E': ['shift_jisx0213', 'shift_jis_2004'],\n\n# '\u555c\u3030\\u3130\u3144\u4531': ['utf_16', 'utf_16_le'],\n\n# '\u5c55\u3030\u3031\u4431\u3145': ['utf_16_be'],\n\n# '\ud834\udd1e': ['raw_unicode_escape', 'unicode_escape']}\n\n######################################################\n\nprint(groupby_percentage(\n\n    seq=10*[1,2,34,4,2,3,54,6,6,4,3,2,21,45,56], percent_true=63.7, continue_on_exceptions=True, withindex=False, withvalue=True\n\n))\n\n# output: {False: [1, 2, 4, 3, 2, 34, 4, 2, 3, 4, 56, 4, 2, 45, 2, 2, 3, 54, 2, 21, 1, 4, 6, 3, 21, 34, 2, 54, 3, 21, 45, 1, 2, 4, 54, 6, 4, 56, 1, 4, 56, 1, 2, 4, 54, 3, 1, 54, 4, 3, 21], True: [2, 34, 4, 3, 54, 6, 6, 21, 45, 56, 1, 2, 54, 6, 6, 3, 2, 21, 45, 1, 2, 34, 2, 3, 54, 6, 6, 4, 3, 21, 56, 1, 34, 4, 6, 6, 4, 3, 45, 56, 2, 34, 2, 3, 54, 6, 4, 2, 45, 56, 1, 2, 4, 3, 6, 6, 4, 2, 56, 34, 2, 3, 6, 3, 2, 21, 45, 2, 34, 2, 3, 54, 6, 6, 4, 3, 2, 21, 45, 34, 2, 3, 6, 6, 4, 2, 21, 45, 56, 2, 34, 4, 2, 3, 6, 6, 2, 45, 56]}\n\n######################################################\n\nprint(groupby_almost_equal(\n\n    seq=[11,200,34,4,52,63,54,65,67,48,3,2,21,55,56,59,61,60], value=60, equallimit=3, continue_on_exceptions=True, withindex=False, withvalue=True\n\n))\n\n# output: {False: [11, 200, 34, 4, 52, 54, 65, 67, 48, 3, 2, 21, 55, 56], True: [63, 59, 61, 60]}\n\n######################################################\n\ncoordlist = 2 * [(1, 2), (34, 4), (2, 3), (61, 60)]\n\nprint(groupby_coords_almost_equal(seq=coordlist, x_coord=4, y_coord=3, limit_x=5, limit_y=1,\n\n                                  continue_on_exceptions=True, withindex=False, withvalue=True))\n\n\n\n# output: {(True, True): [(1, 2), (2, 3), (1, 2), (2, 3)], (False, True): [(34, 4), (34, 4)], (False, False): [(61, 60), (61, 60)]}\n\n######################################################\n\ncoordlist = [(745, 519),\n\n (747, 522),\n\n (747, 517),\n\n (747, 517),\n\n (750, 522),\n\n (756, 449),\n\n (757, 461),\n\n (757, 461),\n\n (757, 438),\n\n (830, 144),\n\n (759, 435),\n\n (759, 435),\n\n (761, 468),\n\n (761, 468),\n\n (764, 521),\n\n (1079, 199),\n\n (770, 474),\n\n (770, 425),\n\n (773, 516),\n\n (776, 515),\n\n (776, 515),\n\n (778, 520),\n\n (779, 519),\n\n (780, 420),\n\n (780, 420),\n\n (782, 478),\n\n (782, 478),\n\n (1083, 151),\n\n (1083, 151),\n\n (1083, 151),\n\n (1083, 151),\n\n (784, 478),\n\n (759, 435),\n\n (784, 478),\n\n (819, 137),\n\n (819, 137),\n\n (819, 137),\n\n (797, 524),\n\n (825, 125),\n\n (826, 149),\n\n (800, 446),\n\n (800, 446),\n\n (801, 517),\n\n (801, 517),\n\n (802, 520),\n\n (802, 520),\n\n (804, 519),\n\n (804, 519),\n\n (808, 431),\n\n (808, 431),\n\n (809, 464),\n\n (809, 464),\n\n (812, 438),\n\n (813, 449)]\n\n\n\nxx=(group_coordinates_by_distance(coordlist, limit_x=10, limit_y=10, continue_on_exceptions=True))\n\nfor x in xx:\n\n    print(x)\n\n\n\n# output: ((813, 449),)\n\n# ((779, 519), (773, 516), (776, 515), (778, 520), (764, 521))\n\n# ((808, 431), (812, 438))\n\n# ((1083, 151),)\n\n# ((830, 144), (826, 149))\n\n# ((761, 468), (757, 461), (770, 474))\n\n# ((825, 125),)\n\n# ((756, 449),)\n\n# ((745, 519), (747, 517), (750, 522), (747, 522))\n\n# ((780, 420), (770, 425))\n\n# ((784, 478), (782, 478))\n\n# ((804, 519), (802, 520), (797, 524), (801, 517))\n\n# ((757, 438), (759, 435))\n\n# ((819, 137),)\n\n# ((809, 464),)\n\n# ((800, 446),)\n\n# ((1079, 199),)\n\n######################################################\n\n```\n\n\n\n\n\n\n\n### Iter stuff\n\n\n\n```python\n\n######################################################\n\nfor _ in iter_enumerate_multiple([3, 4], [55, 55]):\n\n    print(_)\n\n\n\n# output: \n\n(0, 3, 55)\n\n(1, 4, 55)\n\n######################################################\t\n\nfor j in iter__chain([3, 4], [55, 55], [{33:31}, 4,1]):\n\n    print(j)\t\n\n\n\n# output: \n\n3\n\n4\n\n55\n\n55\n\n{33: 31}\n\n4\n\n1\t\n\n######################################################\n\npeople = {1: {\"name\": \"John\", \"age\": \"27\", \"sex\": \"Male\"}, 2: {\"name\": \"Marie\", \"age\": \"22\", \"sex\": \"Female\"},\n\n          3: {\"name\": \"Luna\", \"age\": \"24\", \"sex\": \"Female\"},\n\n          4: {\"name\": \"Peter\", \"age\": \"29\", \"sex\": [\"Female\", \"Male\"], 1: \"xx\", \"sex2\": (\"Female\", \"Male\"), }, }\n\nfor keys, item in iter_nested_dict(people):\n\n    print(keys, item)\n\n\n\n# output: \n\n(1, 'name') John\n\n(1, 'age') 27\n\n(1, 'sex') Male\n\n(2, 'name') Marie\n\n(2, 'age') 22\n\n(2, 'sex') Female\n\n(3, 'name') Luna\n\n(3, 'age') 24\n\n(3, 'sex') Female\n\n(4, 'name') Peter\n\n(4, 'age') 29\n\n(4, 'sex', 0) Female\n\n(4, 'sex', 1) Male\n\n(4, 1) xx\n\n(4, 'sex2', 0) Female\n\n(4, 'sex2', 1) Male\n\n######################################################\n\nfor x in (iter_split_list_into_chunks_fill_rest(n=3, iterable=[1, 2, 3, 4, 4, 2, 21], fillvalue=None)):\n\n    print(x)\n\n\t\n\n# output: \t\n\n(1, 2, 3)\n\n(4, 4, 2)\n\n(21, None, None)\n\n######################################################\n\nprint(\n\n    list(\n\n        iter_cycle_shortest(\n\n            iter1=[33, 133, 35, 3300],\n\n            iter2=[331, 1133, 434, 44, 555, 22, 767, 446, 66, 2234],\n\n        )\n\n    )\n\n)\n\n# output: \n\n# [(33, 331), (133, 1133), (35, 434), (3300, 44), (33, 555), (133, 22), (35, 767), (3300, 446), (33, 66), (133, 2234)]\n\n\n\nprint(\n\n    list(\n\n        iter_cycle_shortest(\n\n            iter1=[331, 1133, 434, 44, 555, 22, 767, 446, 66, 2234],\n\n            iter2=[33, 133, 35, 3300],\n\n        )\n\n    )\n\n)\n\n# output: \n\n# [(331, 33), (1133, 133), (434, 35), (44, 3300), (555, 33), (22, 133), (767, 35), (446, 3300), (66, 33), (2234, 133)]\n\n######################################################\n\nprint(list(iter_reverse_lists_of_list(lis=((323,33,331), (331,552,1)))))\n\n# output: [[331, 33, 323], [1, 552, 331]]\n\n######################################################\n\nprint(list(iter_split_by_index(\"For performance reasons, the value of errors is not checked for validity\", [6, 8, 12, 13, 18])))\n\n# output: ['For pe', 'rf', 'orma', 'n', 'ce re', 'asons, the value of errors is not checked for validity']\n\n\n\nprint(list(iter_split_by_index([32.,3,123,424,4242,4,24,532,54,53254,24,24,24,532,35624,42], [6, 8, 12, 13, 18])))\n\n# output: [[32.0, 3, 123, 424, 4242, 4], [24, 532], [54, 53254, 24, 24], [24], [532, 35624, 42], []]\n\n######################################################\n\nfor kl in iter_get_every_nth_element(iterable=[1,2,3,4,4,5,6,3,2.4,4,5,5,4],start=0, step=2):\n\n    print(kl)\n\n# output: \n\n1\n\n3\n\n4\n\n6\n\n2.4\n\n5\n\n4\n\n######################################################\n\nprint(list(iter_find_same_ending_elements(iters=[list((1,2,3,4)), list((1,2,3,4)), list((5,1,2,3,4))])))\n\n# output: [1, 2, 3, 4]\n\n######################################################\n\nprint(list(iter_find_same_beginning_elements(iters=[list((1,2,3,4)), list((1,2,3,4)), list((1,2,3,4,5))])))\n\n# output: [1, 2, 3, 4]\n\n######################################################\n\nfor x in iter_nested_list_from_item(variable=[244, 244, 2], shape=(2, 3,2)):\n\n    print(x)\n\n# output: [[[244, 244, 2], [244, 244, 2]], [[244, 244, 2], [244, 244, 2]], [[244, 244, 2], [244, 244, 2]]]\n\n#         [[[244, 244, 2], [244, 244, 2]], [[244, 244, 2], [244, 244, 2]], [[244, 244, 2], [244, 244, 2]]]\n\n######################################################\n\nprint(list(iter_repeat_items(iterable=[34,4,23], reps=3)))\n\n# output: [34, 34, 34, 4, 4, 4, 23, 23, 23]\n\n######################################################\n\nprint(iter_count_occurrences_of_item_in_multiple_iterables(iterables=[['hallo', 'mein', 'Freund', 'ou'],['hallo', 'mein', 'Freund', 'oxu']]))\n\n# output: Counter({'hallo': 2, 'mein': 2, 'Freund': 2, 'ou': 1, 'oxu': 1})\n\n######################################################\n\nprint(iter_count_occurrences_of_item_in_multiple_iterables_flatten_everything(iterables=[['hallo', ['mein', 'Freund'], 'ou'],['hallo', ['mein'], 'Freund', 'oxu']]))\n\n# output: Counter({'hallo': 2, 'mein': 2, 'Freund': 2, 'ou': 1, 'oxu': 1})\n\n######################################################\n\nlist1 = [(255, 255, 0), (255, 21, 23), (0, 0, 0), (1, 1, 1)]\n\nlist2 = ['yellow', 'red', 'black', 'black']\n\nprint(list(iter_values_from_list1_based_on_values_of_list2(list1, list2, condition=lambda x: x == 'black')))\n\n# output: [(0, 0, 0), (1, 1, 1)]\n\n######################################################\n\nprint(list(iter_windowed(iterable=[1,23,3,2,34], n=2)))\n\n# output: [(1, 23), (23, 3), (3, 2), (2, 34)]\n\n######################################################\n\nfor subit in iter_batch('ABCDEFG', 3):\n\n    for x in subit:\n\n        print(x, end=' ')\n\n    print()\n\n\n\n# output:\t\n\nA B C \n\nD E F \n\nG \n\n######################################################\n\nnpar = numpy_all_permutations(iterable=list('abcdefghijklmnop'), len_of_each=6)\n\n# output:\n\narray([['a', 'b', 'c', 'd', 'e', 'f'],\n\n       ['a', 'b', 'c', 'd', 'e', 'g'],\n\n       ['a', 'b', 'c', 'd', 'e', 'h'],\n\n       ...,\n\n       ['p', 'o', 'n', 'm', 'l', 'i'],\n\n       ['p', 'o', 'n', 'm', 'l', 'j'],\n\n       ['p', 'o', 'n', 'm', 'l', 'k']], dtype='<U1')\n\n\n\nprint(npar.shape)\n\n(5765760, 6)\n\n######################################################\n\nprint(numpy_random_array_no_reps_beginning_end(iterable=['hallo','du','wie','er', 'ich', 'es'], block_count=3))\n\n# output:\n\n[['du' 'wie' 'es' 'ich' 'er' 'hallo']\n\n ['es' 'hallo' 'ich' 'du' 'wie' 'er']\n\n ['du' 'ich' 'wie' 'er' 'es' 'hallo']]\t\n\n######################################################\n\nl1 = [1, 2, 3]\n\nl2 = [4, 5, 6]\n\nl3 = [7, 8, 9]\n\nfor l11, l22, l33 in iter_nested_for_loop(l1, l2, l3):\n\n    print(l11, l22, l33)\n\n# output:\n\n1 4 7\n\n1 4 8\n\n1 4 9\n\n1 5 7\n\n1 5 8\n\n1 5 9\n\n1 6 7\n\n1 6 8\n\n1 6 9\n\n2 4 7\n\n2 4 8\n\n2 4 9\n\n2 5 7\n\n2 5 8\n\n2 5 9\n\n2 6 7\n\n2 6 8\n\n2 6 9\n\n3 4 7\n\n3 4 8\n\n3 4 9\n\n3 5 7\n\n3 5 8\n\n3 5 9\n\n3 6 7\n\n3 6 8\n\n3 6 9\n\n######################################################\n\nl1 = [1, 2, 3]\n\nl2 = [4, 5, 6]\n\nl3 = [7, 8, 9]\n\nfor ini, l11, l22, l33 in iter_nested_for_loop_enumerate(l1, l2, l3):\n\n    print(ini, l11, l22, l33)\n\n\n\n\n\n# output:\n\n\n\n0 1 4 7\n\n1 1 4 8\n\n2 1 4 9\n\n3 1 5 7\n\n4 1 5 8\n\n5 1 5 9\n\n6 1 6 7\n\n7 1 6 8\n\n8 1 6 9\n\n9 2 4 7\n\n10 2 4 8\n\n11 2 4 9\n\n12 2 5 7\n\n13 2 5 8\n\n14 2 5 9\n\n15 2 6 7\n\n16 2 6 8\n\n17 2 6 9\n\n18 3 4 7\n\n19 3 4 8\n\n20 3 4 9\n\n21 3 5 7\n\n22 3 5 8\n\n23 3 5 9\n\n24 3 6 7\n\n25 3 6 8\n\n26 3 6 9\n\n######################################################\n\nfor i in iter_chain_flatten([332313,5434,2342], {3232,342},312, 331):\n\n    print(i)\n\n\n\n# output:\t\n\n332313\n\n5434\n\n2342\n\n3232\n\n342\n\n312\n\n331\n\n\n\n######################################################\n\nfor ini,cir in enumerate(iter_spiral(radius=10,eccentricity = 1.5,step = 0.1,t = 0)):\n\n    print(cir)\n\n    if ini==15:\n\n        break\n\n\n\n# output:\n\n(1.4925062479170388, 0.09983341664682815)\n\n(2.940199733523725, 0.39733866159012243)\n\n(4.299014201065228, 0.8865606199840189)\n\n(5.526365964017311, 1.557673369234602)\n\n(6.581869214177796, 2.397127693021015)\n\n(7.428020534187105, 3.3878548403702125)\n\n(8.030842966487128, 4.509523810663837)\n\n(8.360480512165985, 5.7388487271961806)\n\n(8.39173457165397, 7.04994218664735)\n\n(8.104534588022096, 8.414709848078962)\n\n(7.484336003522027, 9.803280960675787)\n\n(6.522439580580125, 11.184469031606715)\n\n(5.2162271581794535, 12.526256410423509)\n\n(3.5693100009050576, 13.796296219838446)\n\n(1.5915870375233105, 14.962424799060818)\n\n(-0.700788535230937, 15.993177648664085)\t\t\n\n\n\n######################################################\n\nvara= ['key1','x', 'key2',['one', 'two', 'three']]\n\n\n\n# normal python version\n\nfor k in vara:\n\n    if isinstance(k,list):\n\n        for li in k:\n\n            print(k, li)\n\n    else:\n\n        print(k)\n\n\n\n# output:\t\n\nkey1\n\nx\n\nkey2\n\n['one', 'two', 'three'] one\n\n['one', 'two', 'three'] two\n\n['one', 'two', 'three'] three\n\n\n\n\n\n# same thing, but much shorter:\n\nfor k in iter_nested(iterable=vara):\n\n    print(k)\n\n\n\n# output:\t\t\n\n['key1']\n\n['x']\n\n['key2']\n\n[['one', 'two', 'three'], 'one']\n\n[['one', 'two', 'three'], 'two']\n\n[['one', 'two', 'three'], 'three']\t\n\n\n\n######################################################\n\n# same as iter_nested, but with path to each value\n\nfor k in iter_nested_with_path(iterable=vara):\n\n    print(k)\n\n\n\n# output:\t\n\n[((0,), 'key1')]\n\n[((1,), 'x')]\n\n[((2,), 'key2')]\n\n[((3,), ['one', 'two', 'three']), ((3, 0), 'one')]\n\n[((3,), ['one', 'two', 'three']), ((3, 1), 'two')]\n\n[((3,), ['one', 'two', 'three']), ((3, 2), 'three')]\t\n\n######################################################\n\nprint(list(iter_add_one_item_each_iteration(iterable=vara)))\n\n# output:\t[['key1'], ['key1', 'x'], ['key1', 'x', 'key2'], ['key1', 'x', 'key2', ['one', 'two', 'three']]]\n\n######################################################\n\nprint(list(iter_add_one_item_each_iteration_reverse(iterable=vara)))\n\n# output:\t[[['one', 'two', 'three']], ['key2', ['one', 'two', 'three']], ['x', 'key2', ['one', 'two', 'three']], ['key1', 'x', 'key2', ['one', 'two', 'three']]]\n\n######################################################\n\nfrom ansi.colour.rgb import rgb8, rgb16, rgb256\n\nfrom ansi.colour import fg, bg, fx\n\ntext='bababa'\n\nfor colour in iter_rainbow_colors(num_colors=10):\n\n    print(colour)\n\n    print(\"\".join(list(map(str, (\n\n            fx.bold, bg.brightwhite, fg.brightwhite, rgb256(colour[0], colour[1], colour[2]), text, bg.brightwhite,\n\n            fg.brightwhite, fx.bold, fx.reset,), ))))\n\n# output:\n\n(250, 54, 54)\n\nbababa\n\n(247, 170, 54)\n\nbababa\n\n(202, 247, 23)\n\nbababa\n\n(79, 254, 35)\n\nbababa\n\n(49, 252, 130)\n\nbababa\n\n(27, 248, 248)\n\nbababa\n\n(33, 120, 250)\n\nbababa\n\n(88, 48, 249)\n\nbababa\n\n(207, 25, 252)\n\nbababa\n\n(248, 42, 166)\n\nbababa\n\n######################################################\n\nprint(list(iter_reshape({1: 22, 5: list(range(12))}, [2, [3], {2}, (1, (3,), 2)])))\n\n# output: [[22, 0, [1, 2, 3], {4, 5}, (6, (7, 8, 9), 10, 11)]]\n\n######################################################\n\nfor _ in iter_rotate_left(iterable=[1, 2, 3, 4, 5, 6, 3, 2], n=10, onlyfinal=False ):\n\n    print(_)\n\n[2, 3, 4, 5, 6, 3, 2, 1]\n\n[3, 4, 5, 6, 3, 2, 1, 2]\n\n[4, 5, 6, 3, 2, 1, 2, 3]\n\n[5, 6, 3, 2, 1, 2, 3, 4]\n\n[6, 3, 2, 1, 2, 3, 4, 5]\n\n[3, 2, 1, 2, 3, 4, 5, 6]\n\n[2, 1, 2, 3, 4, 5, 6, 3]\n\n[1, 2, 3, 4, 5, 6, 3, 2]\n\n[2, 3, 4, 5, 6, 3, 2, 1]\n\n[3, 4, 5, 6, 3, 2, 1, 2]\n\n######################################################\n\nfor _ in iter_rotate_right(iterable=[1, 2, 3, 4, 5, 6, 3, 2], n=10, onlyfinal=False ):\n\n    print(_)\n\n[2, 1, 2, 3, 4, 5, 6, 3]\n\n[3, 2, 1, 2, 3, 4, 5, 6]\n\n[6, 3, 2, 1, 2, 3, 4, 5]\n\n[5, 6, 3, 2, 1, 2, 3, 4]\n\n[4, 5, 6, 3, 2, 1, 2, 3]\n\n[3, 4, 5, 6, 3, 2, 1, 2]\n\n[2, 3, 4, 5, 6, 3, 2, 1]\n\n[1, 2, 3, 4, 5, 6, 3, 2]\n\n[2, 1, 2, 3, 4, 5, 6, 3]\n\n[3, 2, 1, 2, 3, 4, 5, 6]\n\n######################################################\n\nfor _ in iter_rotate_left(iterable=[1, 2, 3, 4, 5, 6, 3, 2], n=2, onlyfinal=True ):\n\n    print(_)\n\n[3, 4, 5, 6, 3, 2, 1, 2]    \n\n######################################################\n\nfor _ in iter_rotate_right(iterable=[1, 2, 3, 4, 5, 6, 3, 2], n=2, onlyfinal=True):\n\n    print(_)\n\n[3, 2, 1, 2, 3, 4, 5, 6]    \n\n######################################################\n\nfrom string import ascii_letters\n\nprint(iter_number_of_combinations(it=ascii_letters, k=10))\n\n15820024220\n\n######################################################\t\t\n\nfor k in iter_call_function_over_and_over_with_new_value(f=lambda x: x * 2, x=1):\n\n    print(k)\n\n    if k > 10000.0:\n\n        break\n\n\n\n# output:\n\n1\n\n2\n\n4\n\n8\n\n16\n\n32\n\n64\n\n128\n\n256\n\n512\n\n1024\n\n2048\n\n4096\n\n8192\n\n16384\n\n\n\n\n\nfor k in iter_call_function_over_and_over_with_new_value(f=lambda x: x / 2, x=1):\n\n    print(k)\n\n    if k < 0.001:\n\n        break\n\n\n\n# output:\n\n1\n\n0.5\n\n0.25\n\n0.125\n\n0.0625\n\n0.03125\n\n0.015625\n\n0.0078125\n\n0.00390625\n\n0.001953125\n\n0.0009765625\n\n######################################################\n\nfor x in iter_stop_when_next_item_is_duplicate(\n\n    it=[\n\n        1,\n\n        2,\n\n        3,\n\n        4,\n\n        5,\n\n        6,\n\n        76,\n\n        77,\n\n        77,\n\n        12,\n\n    ]\n\n):\n\n    print(x)\n\n    \n\n# output:\n\n1\n\n2\n\n3\n\n4\n\n5\n\n6\n\n76\n\n77    \n\n######################################################    \n\niterable = [\n\n    (233, 233, 1123, [42, 11, 33, 221, 13]),\n\n    (122, 122, 12312),\n\n    (2121, 212),\n\n    (434, 123, 4243, 32),\n\n    (434, 123, 42423, 3322),\n\n]\n\nfor list1, list2 in iter_nested_one_ahead(iterable):\n\n    areequal = list1[-1] == list2[-1]\n\n    if areequal:\n\n        print(list1)\n\n        print(list2)\n\n\n\n# output:\n\n[(233, 233, 1123, [42, 11, 33, 221, 13]), 233]\n\n[(233, 233, 1123, [42, 11, 33, 221, 13]), 233]\n\n[(122, 122, 12312), 122]\n\n[(122, 122, 12312), 122]\n\n######################################################    \n\niterable = [\n\n    (233, 233, 1123, [42, 11, 33, 221, 13]),\n\n    (122, 122, 12312),\n\n    (2121, 212),\n\n    (434, 123, 4243, 32),\n\n    (434, 123, 42423, 3322),\n\n]\n\nfor ini, p in enumerate(iter_random_values_from_iter_endless(iterable=iterable)):\n\n    if ini == 10:\n\n        break\n\n    print(p)   \n\n# output:\n\n4243\n\n123\n\n1123\n\n3322\n\n42\n\n434\n\n122\n\n32\n\n233\n\n212    \n\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Many useful groupby / itertools functions",
    "version": "0.18",
    "split_keywords": [
        "itertools",
        "groupby"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "efa66a4a8d3feed1463382349dafeb4a7d66b200f14870b29d848f52c6ecc350",
                "md5": "bf64fc6fe8ba44ef9651375a55eaae02",
                "sha256": "55e4a04572afee2c964de3fff37e7bf2e33e665e88ac8fac24741a4f37c36fc0"
            },
            "downloads": -1,
            "filename": "group_and_iter_everything-0.18-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "bf64fc6fe8ba44ef9651375a55eaae02",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 61364,
            "upload_time": "2023-02-08T06:52:51",
            "upload_time_iso_8601": "2023-02-08T06:52:51.403106Z",
            "url": "https://files.pythonhosted.org/packages/ef/a6/6a4a8d3feed1463382349dafeb4a7d66b200f14870b29d848f52c6ecc350/group_and_iter_everything-0.18-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "75d6f8b974489dd288bf14a252dfa5960aec7da2d5c472d536d4e10d0805529e",
                "md5": "e4e031277c7934c152fcfe19c66b8804",
                "sha256": "81941bdabc4d3ce8763f9f6309f111caa39804e4124bb966c287bdd49164426c"
            },
            "downloads": -1,
            "filename": "group_and_iter_everything-0.18.tar.gz",
            "has_sig": false,
            "md5_digest": "e4e031277c7934c152fcfe19c66b8804",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 105047,
            "upload_time": "2023-02-08T06:52:54",
            "upload_time_iso_8601": "2023-02-08T06:52:54.063468Z",
            "url": "https://files.pythonhosted.org/packages/75/d6/f8b974489dd288bf14a252dfa5960aec7da2d5c472d536d4e10d0805529e/group_and_iter_everything-0.18.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-02-08 06:52:54",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "hansalemaos",
    "github_project": "group_and_iter_everything",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "check_if_nan",
            "specs": []
        },
        {
            "name": "ctypes_window_info",
            "specs": []
        },
        {
            "name": "dict_merger_keep_all",
            "specs": []
        },
        {
            "name": "divide_region_into_rectangles",
            "specs": []
        },
        {
            "name": "flatten_any_dict_iterable_or_whatsoever",
            "specs": []
        },
        {
            "name": "flatten_everything",
            "specs": []
        },
        {
            "name": "flexible_partial",
            "specs": []
        },
        {
            "name": "get_consecutive_filename",
            "specs": []
        },
        {
            "name": "hexintcalc",
            "specs": []
        },
        {
            "name": "intersection_grouper",
            "specs": []
        },
        {
            "name": "isiter",
            "specs": []
        },
        {
            "name": "kthread_sleep",
            "specs": []
        },
        {
            "name": "locate_pixelcolor",
            "specs": []
        },
        {
            "name": "nestednop",
            "specs": []
        },
        {
            "name": "numexpr",
            "specs": []
        },
        {
            "name": "numpy",
            "specs": []
        },
        {
            "name": "rect_intersection",
            "specs": []
        },
        {
            "name": "regex",
            "specs": []
        },
        {
            "name": "threadingbatch",
            "specs": []
        },
        {
            "name": "tolerant_isinstance",
            "specs": []
        },
        {
            "name": "xxhash",
            "specs": []
        }
    ],
    "lcname": "group-and-iter-everything"
}
        
Elapsed time: 0.03964s