Skip to main content

Filter list using properties

Project description

You can use mexp to help in filtering a list of objects using find and find_any of elements that mactch properties conditions

Exemple:

file test_mexp.py:

from car_class import Car
from mexp import *


if __name__ == "__main__":
    listTesti = []
    listTesti.append(Car('Jack', 'benlalla', True, 1))
    listTesti.append(Car('Jack2', 'elarrs', False, 5))
    listTesti.append(Car('Marc', 'roro', False, 2))
    result = find(listTesti, lname = 'roro')
    print(result)

File car_class.py

class Car(object):
    def __init__(self, name, lname, active, rank):
        self.name = name
        self.lname = lname
        self.active = active
        self.rank = rank

find_any(list_of_object, **kwargs)

   Args:
       list_of_object: provide a list of objects you want to filter
       kwargs: properties with values you want to use as filter
   Returns:
       A filtered list of objects that match any of the filter properties

def find(list_of_object, **kwargs):

    Args:
        list_of_object: provide a list of objects you want to filter
        kwargs: properties with values you want to use as filter
    Returns:
        A filtered list of objects that match the filter properties

mexp repo

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

mexp-0.0.1.tar.gz (2.2 kB view details)

Uploaded Source

File details

Details for the file mexp-0.0.1.tar.gz.

File metadata

  • Download URL: mexp-0.0.1.tar.gz
  • Upload date:
  • Size: 2.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.1

File hashes

Hashes for mexp-0.0.1.tar.gz
Algorithm Hash digest
SHA256 ac2b170b9c8cf1773f24db44f8bf0984274b660f48320ac41d534e769e8eb6a6
MD5 70017df68eb7bde625816a2d548286cf
BLAKE2b-256 63cb94aa4e9e07ead83afb40f0df3edb661fb6d59b4455a4c08c90ed072daad9

See more details on using hashes here.

Supported by

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