Skip to main content

Collections utilities in Python

Project description

Collections Utilities

Collections utilities in Python.

PyPI PyPI - Python Version PyPI - License PyPI - Downloads PyPI - Downloads Coverage Status GitHub code size in bytes GitHub last commit DeepSource

CollectionsUtil class

Methods

Method Description Parameters Returns
deep_args_to_list Flat deep structure arguments to list. args (tuple) The arguments to flat. list A flatten list.
is_iter Check if object is iterable. obj The object to check. bool True if iterable, False otherwise.

Examples:

  • CollectionsUtil.deep_args_to_list

    Code

    from collections_utils import CollectionsUtil
    
    # Flat deep structure arguments to list
    flat_args = CollectionsUtil.deep_args_to_list(1, 2, (3, 4, (5, 6, (7, 8, 9))))
    print(flat_args)
    

    Output

    [1, 2, 3, 4, 5, 6, 7, 8, 9]
    
  • CollectionsUtil.is_iter

    Code

    from collections_utils import CollectionsUtil
    
    # Check if object is iterable
    print(CollectionsUtil.is_iter(1))
    print(CollectionsUtil.is_iter([1, 2, 3]))
    

    Output

    False
    True
    

ListUtil class

Methods

Method Description Parameters Returns
compare_lists Compare two lists. list_1 (list) List 1.
list_2 (list) List 2.
bool True if lists are equal, False otherwise.
remove_none Remove None values. list_ (list) The list to remove None values from. list The list without None values.
remove_duplicates Remove duplicates. list_ (list) The list to remove duplicates from. list The list without duplicates.

Examples:

  • ListUtil.compare_lists

    Code

    from collections_utils import ListUtil
    
    # Compare two lists
    print(ListUtil.compare_lists([1, 3, 2], [1, 2, 3]))
    print(ListUtil.compare_lists([1, 2, 3], [1, 2, 4]))
    

    Output

    True
    False
    
  • ListUtil.remove_none

    Code

    from collections_utils import ListUtil
    
    # Remove None values
    print(ListUtil.remove_none([1, None, 2, None, 3]))
    

    Output

    [1, 2, 3]
    
  • ListUtil.remove_duplicates

    Code

    from collections_utils import ListUtil
    
    # Remove duplicates
    print(ListUtil.remove_duplicates([1, 2, 3, 1, 2, 3]))
    

    Output

    [1, 2, 3]
    

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nrt_collections_utils-1.0.0.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

nrt_collections_utils-1.0.0-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file nrt_collections_utils-1.0.0.tar.gz.

File metadata

  • Download URL: nrt_collections_utils-1.0.0.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.0

File hashes

Hashes for nrt_collections_utils-1.0.0.tar.gz
Algorithm Hash digest
SHA256 18549aa5e6a49ca228a4a0ed92b98964a07f353bd1f8cd7f03a572f014d38fa4
MD5 163bd47c43c15c55c1bb6c1fb1df59ad
BLAKE2b-256 a7c84a6167fea6d3588153e61a0184614885069df508294c81028f70aa46a2ff

See more details on using hashes here.

File details

Details for the file nrt_collections_utils-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for nrt_collections_utils-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b8ee763162ee1559d7022bdb3fd8c6691144c4bcfc6d4f544de63381a6796bc3
MD5 e8c110cce4c7e44482dc2c41ebbcfde1
BLAKE2b-256 84a8b2f4cd7a765d408f2e477aa7dda8afd3af26e510c22aa77c67e1ed827aca

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page