New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

list-utilities

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

list-utilities

A Python package for common list operations such as removing duplicates and flattening lists.

0.1.1
PyPI
Maintainers
1

List Utilities

List Utilities is a simple Python package that provides utility functions for common list operations, including removing duplicates and flattening nested lists.

Installation

You can install the package using pip:

pip install list_utilities

Functions Descriptions

First Function: remove_duplicates(input_list) Description: This function takes a list as input and returns a new list that contains the unique elements from the original list, preserving their original order. It effectively removes any duplicate entries without altering the sequence of the remaining items.

Parameters: input_list (list): A list of elements from which duplicates need to be removed. The elements can be of any data type (e.g., integers, strings). Returns:

(list): A list containing only unique elements from the input_list.

Example:

from list_utilities import remove_duplicates

my_list = [1, 2, 2, 3, 4, 4, 5] unique_list = remove_duplicates(my_list) print(unique_list)

Output:

[1, 2, 3, 4, 5]

Second Function: flatten_list(nested_list) Description: This function flattens a nested list, which may contain other lists at any level of depth, into a single list. It recursively traverses through all elements and sub-elements, collecting them into a single flat structure.

Parameters:

nested_list (list): A list that may contain other lists as elements. The nesting can be at multiple levels. Returns:

(list): A single list that includes all elements from the nested_list, with no nesting. Example:

from list_utilities import flatten_list

nested = [[1, 2], [3, 4, [5, 6]], 7] flat = flatten_list(nested) print(flat)

Output:

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

License This project is licensed under the MIT License - see the LICENSE file for details.

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts