<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)
customersMaleEnumerable.Loop(lambda customer: 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": null,
"docs_url": null,
"requires_python": ">=3",
"maintainer_email": null,
"keywords": "linq, linqex, ex, enumerable",
"author": "TahsinCr",
"author_email": "TahsinCr@outlook.com",
"download_url": "https://files.pythonhosted.org/packages/73/0d/a974f706dae6e7abd5d9b59d80115e83b59b452249add6ac14e50dcbb459/linqex-1.6.3.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\ncustomersMaleEnumerable.Loop(lambda customer: 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.3",
"project_urls": {
"Homepage": "https://github.com/TahsinCr/python-linqex"
},
"split_keywords": [
"linq",
" linqex",
" ex",
" enumerable"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b23aceb8a4bba06627bff723de23e1b5093dd172754513b1d16eee4e1dec3f58",
"md5": "0cc061fe3a56cda2a4f63081a6b4ac8e",
"sha256": "e8959328a7cca758bca9c442dc09dfc6828a5c669dd33353e814547a4c2a38c8"
},
"downloads": -1,
"filename": "linqex-1.6.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "0cc061fe3a56cda2a4f63081a6b4ac8e",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3",
"size": 21199,
"upload_time": "2024-08-29T21:42:07",
"upload_time_iso_8601": "2024-08-29T21:42:07.570691Z",
"url": "https://files.pythonhosted.org/packages/b2/3a/ceb8a4bba06627bff723de23e1b5093dd172754513b1d16eee4e1dec3f58/linqex-1.6.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "730da974f706dae6e7abd5d9b59d80115e83b59b452249add6ac14e50dcbb459",
"md5": "0ebb15636b25ab94e8a9862d8b51b93e",
"sha256": "3dcab21b3963a3caef16efdf766b13167b78d6ed7eeb970ced1e27ae3350bdac"
},
"downloads": -1,
"filename": "linqex-1.6.3.tar.gz",
"has_sig": false,
"md5_digest": "0ebb15636b25ab94e8a9862d8b51b93e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3",
"size": 15871,
"upload_time": "2024-08-29T21:42:09",
"upload_time_iso_8601": "2024-08-29T21:42:09.117873Z",
"url": "https://files.pythonhosted.org/packages/73/0d/a974f706dae6e7abd5d9b59d80115e83b59b452249add6ac14e50dcbb459/linqex-1.6.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-29 21:42:09",
"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"
}