linqex


Namelinqex JSON
Version 1.6.2 PyPI version JSON
download
home_pagehttps://github.com/TahsinCr/python-linqex
SummaryThe linq module in C# has been adapted for python with some modifications.
upload_time2024-01-28 23:41:37
maintainer
docs_urlNone
authorTahsinCr
requires_python>=3
licenseMIT
keywords linq linqex ex enumerable
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <a name="readme-top"></a>

[![Contributors][contributors-shield]][contributors-url]
[![Forks][forks-shield]][forks-url]
[![Stargazers][stars-shield]][stars-url]
[![Issues][issues-shield]][issues-url]
[![MIT License][license-shield]][license-url]
[![LinkedIn][linkedin-shield]][linkedin-url]







<!-- About -->
<div align="center">

<h3 align="center">Python Linqex</h3>

<p align="center">

The linq module in C# has been adapted for python with some modifications.

<a href="https://github.com/TahsinCr/python-linqex/blob/master/CHANGELOG.md">Changelog</a>
 · 
<a href="https://github.com/TahsinCr/python-linqex/issues">Report Bug</a>
 · 
<a href="https://github.com/TahsinCr/python-linqex/issues">Request Feature</a>
 
</p>

</div>



<!-- ABOUT THE PROJECT -->

##  About The Project

Provides simple to use LINQ features to Python 3.x.



###  Built With

* [![Python][Python]][Python-url]

<br>


<!-- GETTING STARTED -->

##  Getting Started

To get a local copy up and running follow these simple example steps.

###  Prerequisites

Does not require any prerequisites

###  Installation

1. Clone the repo
```sh
git clone https://github.com/TahsinCr/python-linqex.git
```

2. Install PIP packages
```sh
pip install linqex
```


<br>



<!-- USAGE EXAMPLES -->

##  Usage

Let's have different customers. Let's choose the male ones among these customers. For this:
```python
from linqex.linq import Enumerable
customersList = [
    {'name' : 'Jonh', 'age' : 25, 'gender': 'male'},
    {'name' : 'Emma', 'age' : 44, 'gender': 'female'},
    {'name' : 'Steve', 'age' : 17, 'gender': 'male'}
]

customersEnumerable = Enumerable(customersList)

# to select only male ones:
customersMaleEnumerable = customersEnumerable.Where(lambda key, value: value['gender'] == 'male')

for customer in customersMaleEnumerable.ToList:
    print(customer)

```
Output
```
{'name' : 'Jonh', 'age' : 25, 'gender': 'male'}
{'name' : 'Steve', 'age' : 17, 'gender': 'male'}
```

<br>

Let's develop the example we wrote above a bit further:
```python
from typing import Literal
from linqex.linq import Enumerable

MALE = "MALE"
FEMALE = "FEMALE"

class Customer:
    def __init__(self, id:int, name:str, age:int, gender:Literal["MALE","FEMALE"]):
        self.id = id
        self.name = name
        self.age = age
        self.gender = gender


customerList = [
    Customer(1, "Ava", 32, MALE),
    Customer(2, "Alex", 19, MALE),
    Customer(3, "Amelia", 22, FEMALE),
    Customer(4, "Arnold", 43, MALE),
    Customer(5, "Eric", 55, MALE),
    Customer(6, "Lily", 12, FEMALE),
    Customer(7, "Jessia", 32, MALE),
    Customer(8, "William", 19, MALE),
    Customer(9, "Emily", 22, FEMALE),
    Customer(10, "Mateo", 43, MALE),
    Customer(11, "Antony", 55, MALE),
    Customer(12, "Mia", 12, FEMALE)
]

customerEnumerable = Enumerable.List(customerList)

# to select only male ones:
customersMaleEnumerable = customerEnumerable.Where(lambda customer: customer.gender == MALE)

for customer in customersMaleEnumerable.ToList:
    print(customer.__dict__)

```
Output
```
{'id': 1, 'name': 'Ava', 'age': 32, 'gender': 'MALE'}
{'id': 2, 'name': 'Alex', 'age': 19, 'gender': 'MALE'}
{'id': 4, 'name': 'Arnold', 'age': 43, 'gender': 'MALE'}
{'id': 5, 'name': 'Eric', 'age': 55, 'gender': 'MALE'}
{'id': 7, 'name': 'Jessia', 'age': 32, 'gender': 'MALE'}
{'id': 8, 'name': 'William', 'age': 19, 'gender': 'MALE'}
{'id': 10, 'name': 'Mateo', 'age': 43, 'gender': 'MALE'}
{'id': 11, 'name': 'Antony', 'age': 55, 'gender': 'MALE'}
```

_For more examples, please refer to the [Documentation](https://github.com/TahsinCr/python-linqex/wiki)_




<!-- LICENSE -->

##  License

Distributed under the MIT License. See `LICENSE.txt` for more information.


<br>





<!-- CONTACT -->

##  Contact

Tahsin Çirkin - [@TahsinCrs](https://twitter.com/TahsinCrs) - TahsinCr@outlook.com

Project Link: [https://github.com/TahsinCr/python-linqex](https://github.com/TahsinCr/python-linqex)








<!-- LINKS & IMAGES URL -->

[contributors-shield]: https://img.shields.io/github/contributors/TahsinCr/python-linqex.svg?style=for-the-badge

[contributors-url]: https://github.com/TahsinCr/python-linqex/graphs/contributors

[forks-shield]: https://img.shields.io/github/forks/TahsinCr/python-linqex.svg?style=for-the-badge

[forks-url]: https://github.com/TahsinCr/python-linqex/network/members

[stars-shield]: https://img.shields.io/github/stars/TahsinCr/python-linqex.svg?style=for-the-badge

[stars-url]: https://github.com/TahsinCr/python-linqex/stargazers

[issues-shield]: https://img.shields.io/github/issues/TahsinCr/python-linqex.svg?style=for-the-badge

[issues-url]: https://github.com/TahsinCr/python-linqex/issues

[license-shield]: https://img.shields.io/github/license/TahsinCr/python-linqex.svg?style=for-the-badge

[license-url]: https://img.shields.io/github/forks/TahsinCr/python-linqex?style=flat-square

[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge&logo=linkedin&colorB=555

[linkedin-url]: https://linkedin.com/in/TahsinCr

[Python]: https://img.shields.io/pypi/pyversions/linqex?style=flat-square

[Python-url]: https://pypi.org/project/linqex

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/TahsinCr/python-linqex",
    "name": "linqex",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3",
    "maintainer_email": "",
    "keywords": "linq,linqex,ex,enumerable",
    "author": "TahsinCr",
    "author_email": "TahsinCr@outlook.com",
    "download_url": "https://files.pythonhosted.org/packages/cc/f1/33914d534140eb4758e638a745583795b11eec11c444589bd8b093345596/linqex-1.6.2.tar.gz",
    "platform": null,
    "description": "<a name=\"readme-top\"></a>\r\n\r\n[![Contributors][contributors-shield]][contributors-url]\r\n[![Forks][forks-shield]][forks-url]\r\n[![Stargazers][stars-shield]][stars-url]\r\n[![Issues][issues-shield]][issues-url]\r\n[![MIT License][license-shield]][license-url]\r\n[![LinkedIn][linkedin-shield]][linkedin-url]\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n<!-- About -->\r\n<div align=\"center\">\r\n\r\n<h3 align=\"center\">Python Linqex</h3>\r\n\r\n<p align=\"center\">\r\n\r\nThe linq module in C# has been adapted for python with some modifications.\r\n\r\n<a href=\"https://github.com/TahsinCr/python-linqex/blob/master/CHANGELOG.md\">Changelog</a>\r\n \u00b7 \r\n<a href=\"https://github.com/TahsinCr/python-linqex/issues\">Report Bug</a>\r\n \u00b7 \r\n<a href=\"https://github.com/TahsinCr/python-linqex/issues\">Request Feature</a>\r\n \r\n</p>\r\n\r\n</div>\r\n\r\n\r\n\r\n<!-- ABOUT THE PROJECT -->\r\n\r\n##  About The Project\r\n\r\nProvides simple to use LINQ features to Python 3.x.\r\n\r\n\r\n\r\n###  Built With\r\n\r\n* [![Python][Python]][Python-url]\r\n\r\n<br>\r\n\r\n\r\n<!-- GETTING STARTED -->\r\n\r\n##  Getting Started\r\n\r\nTo get a local copy up and running follow these simple example steps.\r\n\r\n###  Prerequisites\r\n\r\nDoes not require any prerequisites\r\n\r\n###  Installation\r\n\r\n1. Clone the repo\r\n```sh\r\ngit clone https://github.com/TahsinCr/python-linqex.git\r\n```\r\n\r\n2. Install PIP packages\r\n```sh\r\npip install linqex\r\n```\r\n\r\n\r\n<br>\r\n\r\n\r\n\r\n<!-- USAGE EXAMPLES -->\r\n\r\n##  Usage\r\n\r\nLet's have different customers. Let's choose the male ones among these customers. For this:\r\n```python\r\nfrom linqex.linq import Enumerable\r\ncustomersList = [\r\n    {'name' : 'Jonh', 'age' : 25, 'gender': 'male'},\r\n    {'name' : 'Emma', 'age' : 44, 'gender': 'female'},\r\n    {'name' : 'Steve', 'age' : 17, 'gender': 'male'}\r\n]\r\n\r\ncustomersEnumerable = Enumerable(customersList)\r\n\r\n# to select only male ones:\r\ncustomersMaleEnumerable = customersEnumerable.Where(lambda key, value: value['gender'] == 'male')\r\n\r\nfor customer in customersMaleEnumerable.ToList:\r\n    print(customer)\r\n\r\n```\r\nOutput\r\n```\r\n{'name' : 'Jonh', 'age' : 25, 'gender': 'male'}\r\n{'name' : 'Steve', 'age' : 17, 'gender': 'male'}\r\n```\r\n\r\n<br>\r\n\r\nLet's develop the example we wrote above a bit further:\r\n```python\r\nfrom typing import Literal\r\nfrom linqex.linq import Enumerable\r\n\r\nMALE = \"MALE\"\r\nFEMALE = \"FEMALE\"\r\n\r\nclass Customer:\r\n    def __init__(self, id:int, name:str, age:int, gender:Literal[\"MALE\",\"FEMALE\"]):\r\n        self.id = id\r\n        self.name = name\r\n        self.age = age\r\n        self.gender = gender\r\n\r\n\r\ncustomerList = [\r\n    Customer(1, \"Ava\", 32, MALE),\r\n    Customer(2, \"Alex\", 19, MALE),\r\n    Customer(3, \"Amelia\", 22, FEMALE),\r\n    Customer(4, \"Arnold\", 43, MALE),\r\n    Customer(5, \"Eric\", 55, MALE),\r\n    Customer(6, \"Lily\", 12, FEMALE),\r\n    Customer(7, \"Jessia\", 32, MALE),\r\n    Customer(8, \"William\", 19, MALE),\r\n    Customer(9, \"Emily\", 22, FEMALE),\r\n    Customer(10, \"Mateo\", 43, MALE),\r\n    Customer(11, \"Antony\", 55, MALE),\r\n    Customer(12, \"Mia\", 12, FEMALE)\r\n]\r\n\r\ncustomerEnumerable = Enumerable.List(customerList)\r\n\r\n# to select only male ones:\r\ncustomersMaleEnumerable = customerEnumerable.Where(lambda customer: customer.gender == MALE)\r\n\r\nfor customer in customersMaleEnumerable.ToList:\r\n    print(customer.__dict__)\r\n\r\n```\r\nOutput\r\n```\r\n{'id': 1, 'name': 'Ava', 'age': 32, 'gender': 'MALE'}\r\n{'id': 2, 'name': 'Alex', 'age': 19, 'gender': 'MALE'}\r\n{'id': 4, 'name': 'Arnold', 'age': 43, 'gender': 'MALE'}\r\n{'id': 5, 'name': 'Eric', 'age': 55, 'gender': 'MALE'}\r\n{'id': 7, 'name': 'Jessia', 'age': 32, 'gender': 'MALE'}\r\n{'id': 8, 'name': 'William', 'age': 19, 'gender': 'MALE'}\r\n{'id': 10, 'name': 'Mateo', 'age': 43, 'gender': 'MALE'}\r\n{'id': 11, 'name': 'Antony', 'age': 55, 'gender': 'MALE'}\r\n```\r\n\r\n_For more examples, please refer to the [Documentation](https://github.com/TahsinCr/python-linqex/wiki)_\r\n\r\n\r\n\r\n\r\n<!-- LICENSE -->\r\n\r\n##  License\r\n\r\nDistributed under the MIT License. See `LICENSE.txt` for more information.\r\n\r\n\r\n<br>\r\n\r\n\r\n\r\n\r\n\r\n<!-- CONTACT -->\r\n\r\n##  Contact\r\n\r\nTahsin \u00c7irkin - [@TahsinCrs](https://twitter.com/TahsinCrs) - TahsinCr@outlook.com\r\n\r\nProject Link: [https://github.com/TahsinCr/python-linqex](https://github.com/TahsinCr/python-linqex)\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n<!-- LINKS & IMAGES URL -->\r\n\r\n[contributors-shield]: https://img.shields.io/github/contributors/TahsinCr/python-linqex.svg?style=for-the-badge\r\n\r\n[contributors-url]: https://github.com/TahsinCr/python-linqex/graphs/contributors\r\n\r\n[forks-shield]: https://img.shields.io/github/forks/TahsinCr/python-linqex.svg?style=for-the-badge\r\n\r\n[forks-url]: https://github.com/TahsinCr/python-linqex/network/members\r\n\r\n[stars-shield]: https://img.shields.io/github/stars/TahsinCr/python-linqex.svg?style=for-the-badge\r\n\r\n[stars-url]: https://github.com/TahsinCr/python-linqex/stargazers\r\n\r\n[issues-shield]: https://img.shields.io/github/issues/TahsinCr/python-linqex.svg?style=for-the-badge\r\n\r\n[issues-url]: https://github.com/TahsinCr/python-linqex/issues\r\n\r\n[license-shield]: https://img.shields.io/github/license/TahsinCr/python-linqex.svg?style=for-the-badge\r\n\r\n[license-url]: https://img.shields.io/github/forks/TahsinCr/python-linqex?style=flat-square\r\n\r\n[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge&logo=linkedin&colorB=555\r\n\r\n[linkedin-url]: https://linkedin.com/in/TahsinCr\r\n\r\n[Python]: https://img.shields.io/pypi/pyversions/linqex?style=flat-square\r\n\r\n[Python-url]: https://pypi.org/project/linqex\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "The linq module in C# has been adapted for python with some modifications.",
    "version": "1.6.2",
    "project_urls": {
        "Homepage": "https://github.com/TahsinCr/python-linqex"
    },
    "split_keywords": [
        "linq",
        "linqex",
        "ex",
        "enumerable"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3275ac982fbf93e6a10ea82524e3d87e09c2d46cda6bae81e97654f8596c66e6",
                "md5": "1d95a7a96d70389f515eb1085dff0f4e",
                "sha256": "a14ee626c0194b8af5b9240bfa317e0232ddae6044d8fd8cc665cdc8223da378"
            },
            "downloads": -1,
            "filename": "linqex-1.6.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1d95a7a96d70389f515eb1085dff0f4e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3",
            "size": 27536,
            "upload_time": "2024-01-28T23:41:35",
            "upload_time_iso_8601": "2024-01-28T23:41:35.969423Z",
            "url": "https://files.pythonhosted.org/packages/32/75/ac982fbf93e6a10ea82524e3d87e09c2d46cda6bae81e97654f8596c66e6/linqex-1.6.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ccf133914d534140eb4758e638a745583795b11eec11c444589bd8b093345596",
                "md5": "7a72438cdf60251f3af9092922248a4c",
                "sha256": "8468b9edc3cc97c5df6282ea7a48202510cc373a2ffdc854b1f4bc2039a4bc41"
            },
            "downloads": -1,
            "filename": "linqex-1.6.2.tar.gz",
            "has_sig": false,
            "md5_digest": "7a72438cdf60251f3af9092922248a4c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3",
            "size": 19001,
            "upload_time": "2024-01-28T23:41:37",
            "upload_time_iso_8601": "2024-01-28T23:41:37.404536Z",
            "url": "https://files.pythonhosted.org/packages/cc/f1/33914d534140eb4758e638a745583795b11eec11c444589bd8b093345596/linqex-1.6.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-28 23:41:37",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "TahsinCr",
    "github_project": "python-linqex",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "linqex"
}
        
Elapsed time: 0.18204s