MCPcopy
hub / github.com/omkarcloud/botasaurus / flatten

Function flatten

botasaurus/list_utils.py:36–61  ·  view source on GitHub ↗

Flattens array a single level deep. Args: array (list): List to flatten. Returns: list: Flattened list. Example: >>> flatten([[1], [2, [3]], [[4]]]) [1, 2, [3], [4]] .. versionadded:: 1.0.0 .. versionchanged:: 2.0.0

(array)

Source from the content-addressed store, hash-verified

34 return list(iterflatten(array, depth=depth))
35
36def flatten(array):
37 """
38 Flattens array a single level deep.
39
40 Args:
41 array (list): List to flatten.
42
43 Returns:
44 list: Flattened list.
45
46 Example:
47
48 >>> flatten([[1], [2, [3]], [[4]]])
49 [1, 2, [3], [4]]
50
51
52 .. versionadded:: 1.0.0
53
54 .. versionchanged:: 2.0.0
55 Removed `callback` option. Added ``is_deep`` option. Made it shallow
56 by default.
57
58 .. versionchanged:: 4.0.0
59 Removed ``is_deep`` option. Use :func:`flatten_deep` instead.
60 """
61 return flatten_depth(array, depth=1)
62
63def flatten_deep(array):
64 """

Callers 5

_workerFunction · 0.70
_workerFunction · 0.70
_workerFunction · 0.70
get_sitemaps_from_robotsFunction · 0.70
getMethod · 0.70

Calls 1

flatten_depthFunction · 0.85

Tested by

no test coverage detected