avilum / Linqit
Licence: apache-2.0
Extend python lists with .NET's LINQ syntax for clean and fast coding. Also known as PINQ.
Stars: ✭ 222
Programming Languages
python
139335 projects - #7 most used programming language
python3
1442 projects
csharp
926 projects
metaprogramming
66 projects
Projects that are alternatives of or similar to Linqit
clean-code-php
Persian translation of clean code concepts in PHP | ترجمه فارسی مفاهیم کد تمیز در پی اچ پی
Stars: ✭ 38 (-82.88%)
Mutual labels: clean-code, clean
js-symbol-tree
Turn any collection of objects into its own efficient tree or linked list using Symbol
Stars: ✭ 86 (-61.26%)
Mutual labels: metadata, efficiency
Discord bot.py
🍺 A simple discord bot that helps you getting started within discord.py
Stars: ✭ 313 (+40.99%)
Mutual labels: clean, clean-code
birthday.py
🎉 A simple discord bot in discord.py that helps you understand the usage of SQL databases
Stars: ✭ 30 (-86.49%)
Mutual labels: clean-code, clean
Geoportal Server
Geoportal Server is a standards-based, open source product that enables discovery and use of geospatial resources including data and services.
Stars: ✭ 210 (-5.41%)
Mutual labels: metadata
Vuvuzela
Private messaging system that hides metadata
Stars: ✭ 2,423 (+991.44%)
Mutual labels: metadata
Clean Architecture Android
Sample to practice Clean Architecture in android applications.
Stars: ✭ 207 (-6.76%)
Mutual labels: clean
Shields
Concise, consistent, and legible badges in SVG and raster format
Stars: ✭ 15,716 (+6979.28%)
Mutual labels: metadata
Dev Tools
The most popular software developer tools in one app
Stars: ✭ 221 (-0.45%)
Mutual labels: development-tools
Sfpowerkit
A Salesforce DX Plugin with multiple functionalities aimed at improving development and operational workflows
Stars: ✭ 214 (-3.6%)
Mutual labels: metadata
Bookmarks
🔖 +4.3K awesome resources for geeks and software crafters 🍺
Stars: ✭ 210 (-5.41%)
Mutual labels: clean-code
Mongodb.entities
A data access library for MongoDB with an elegant api, LINQ support and built-in entity relationship management
Stars: ✭ 204 (-8.11%)
Mutual labels: linq
Frappejs
Node + Electron + Vue based metadata web framework (inspired by Frappe)
Stars: ✭ 214 (-3.6%)
Mutual labels: metadata
Structured Filter
jQuery UI widget for structured queries like "Contacts where Firstname starts with A and Birthday before 1/1/2000 and State in (CA, NY, FL)"...
Stars: ✭ 213 (-4.05%)
Mutual labels: metadata
Linqit!
Extends python's list builtin with fun, robust functionality - .NET's Language Integrated Queries (Linq) and more.
Write clean code with powerful syntax.
pip install linqit
Stop using loops, complex conditions, list comperhension and filters.
Doesn't it looks better?
from seven_dwwarfs import Grumpy, Happy, Sleepy, Bashful, Sneezy, Dopey, Doc
from linqit import List
# Go ahead and fill the list with whatever you want... like a list of <Programmer> objects.
programmers = List()
Avi = type("Avi", (), {})
elon_musk = Entrepreneur(talented=True)
# Then play:
last_hot_pizza_slice = (
programmers.where(lambda e: e.experience > 15)
.except_for(elon_musk)
.of_type(Avi)
.take(3) # [<Avi>, <Avi>, <Avi>]
.select(lambda avi: avi.lunch) # [<Pizza>, <Pizza>, <Pizza>]
.where(lambda p: p.is_hot() and p.origin != "Pizza Hut")
.last() # <Pizza>
.slices.last() # <PizzaSlice>
)
# What do you think?
We all use multiple aggregations in our code, while multiple filters/comprehensions are not pythonic at all.
The whole idea is is to use it for nested, multiple filters/modifications :).
Some of the methods might look ridiculous for a single calls, comparing to the regular python syntax.
Here are some use cases:
Methods:
all
any
concat
contains
distinct
except_for
first
get_by_attr
intersect
last
select
skip
take
where
of_type
Properties:
sum
min
max
avg
sorted
Deeper - Let's play with a list of people, a custom type.
import List
class Person():
def __init__(self, name, age):
self.name = name
self.age = age
def __repr__(self):
return 'Person(name="{}", age={})'.format(self.name, self.age)
# Creating a list of people
avi, bill, bob, harry = Person('Avi', 23), Person('Bill', 41), Person('Bob', 77), Person('Harry', 55)
people = List(avi, bill, bob, harry)
Use LINQ selections, write cleaner code
old_people = people.where(lambda p: p.age > 23) # It's a joke! :) [<Person name="Bill" age="41">, <Person name="Bob" age="77">, <Person name="Harry" age="55">]
old_people.first() # <Person name="Bill" age="41">
old_people.last() # <Person name="Harry" age="55">
old_people.any(lambda p: p.name.lower().startswith('b')) # True
old_people.where(lambda p: p.age == 55) # [<Person name="Harry" age="55">]
old_people.skip(3).any() # False
old_people.skip(2).first() # <Person name="Harry" age="55">
# Isn't it better than "for", "if", "else", "filter", "map" and list comprehensions in the middle of your code?
More selections
new_kids_in_town = [Person('Chris', 18), Person('Danny', 16), Person('John', 17)]
people += new_kids_in_town # Also works: people = people.concat(new_kids_in_town)
teenagers = people.where(lambda p: 20 >= p.age >= 13)
danny = teenagers.first(lambda t: t.name == 'Danny') # <Person name="Danny" age="16">
oldest_teen = teenagers.order_by(lambda t: t.age).last() # <Person name="John" age="17">
Let's make python more dynamic
names = people.name # ['Avi', 'Bill', 'Bob', 'Harry', 'Chris', 'John']
ages = people.age # [23, 41, 77, 55, 18, 17]
teenagers_names = teenagers.name # ['Chris', 'Danny', 'John']
teenagers_names.take(2).except_for(lambda n: n == 'Danny') # ['Chris']
teenagers.age.min # 16
teenagers.age.avg # 17
teenagers.age.max # 18
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].