kyu_5.flatten package

Submodules

kyu_5.flatten.flatten module

kyu_5.flatten.flatten.flatten(*args)[source]

The method takes in any number of arguments and flattens them into a single array. If any of the arguments passed in are an array then the individual objects within the array will be flattened so that they exist at the same level as the other arguments. Any nested arrays, no matter how deep, should be flattened into the single array result. :return:

kyu_5.flatten.flatten.unpack(data, collection: list)[source]

Helper method. Unpack data until its not list or a tuple. :param data: :param collection: :return:

kyu_5.flatten.test_flatten module

class kyu_5.flatten.test_flatten.FlattenTestCase(methodName='runTest')[source]

Bases: unittest.case.TestCase

Testing flatten function

test_flatten()[source]

For this exercise you will create a global flatten method. The method takes in any number of arguments and flattens them into a single array. If any of the arguments passed in are an array then the individual objects within the array will be flattened so that they exist at the same level as the other arguments. Any nested arrays, no matter how deep, should be flattened into the single array result.

The following are examples of how this function would be used and what the expected results would be:

flatten(1, [2, 3], 4, 5, [6, [7]]) # returns [1, 2, 3, 4, 5, 6, 7] flatten(‘a’, [‘b’, 2], 3, None, [[4], [‘c’]]) # returns [‘a’, ‘b’, 2, 3, None, 4, ‘c’] :return:

Module contents