All Projects → serkanyersen → Underscore.py

serkanyersen / Underscore.py

Licence: mit
Python port of underscore.js

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Underscore.py

pmm
PyPi Mirror Manager
Stars: ✭ 29 (-89.53%)
Mutual labels:  pypi, pip
Py webauthn
A WebAuthn Python module.
Stars: ✭ 270 (-2.53%)
Mutual labels:  pypi, pip
ios2androidres
Copy iOS image resources to their appropriate Android directory
Stars: ✭ 20 (-92.78%)
Mutual labels:  pypi, pip
Rules python
Experimental Bazel Python Rules
Stars: ✭ 233 (-15.88%)
Mutual labels:  pypi, pip
poetry-setup
Generate setup.py (setuptools) from pyproject.toml (poetry)
Stars: ✭ 44 (-84.12%)
Mutual labels:  pypi, pip
yavdb
Yet Another Vulnerability Database
Stars: ✭ 14 (-94.95%)
Mutual labels:  pypi, pip
pystyle
The source of my Python library, pystyle.
Stars: ✭ 158 (-42.96%)
Mutual labels:  pypi, pip
Pigar
☕️ A fantastic tool to generate requirements.txt for your Python project, and more than that. (IT IS NOT A PACKAGE MANAGEMENT TOOL)
Stars: ✭ 1,068 (+285.56%)
Mutual labels:  pypi, pip
pipyuan
pipyuan 内置了国内常用的 pip 源, 你可以快速设置想要的源
Stars: ✭ 30 (-89.17%)
Mutual labels:  pypi, pip
pip-download
A wrapper for pip download in offline scenario.
Stars: ✭ 22 (-92.06%)
Mutual labels:  pypi, pip
Fades
fades is a system that automatically handles the virtualenvs in the cases normally found when writing scripts and simple programs, and even helps to administer big projects.
Stars: ✭ 182 (-34.3%)
Mutual labels:  pypi, pip
pipsalabim
An assistant to guess your pip dependencies from your code, without using a requirements file.
Stars: ✭ 15 (-94.58%)
Mutual labels:  pypi, pip
Audioowl
Fast and simple music and audio analysis using RNN in Python 🕵️‍♀️ 🥁
Stars: ✭ 151 (-45.49%)
Mutual labels:  pypi, pip
PyGLM
Fast OpenGL Mathematics (GLM) for Python
Stars: ✭ 167 (-39.71%)
Mutual labels:  pypi, pip
Dephell
📦 🔥 Python project management. Manage packages: convert between formats, lock, install, resolve, isolate, test, build graph, show outdated, audit. Manage venvs, build package, bump version.
Stars: ✭ 1,730 (+524.55%)
Mutual labels:  pypi, pip
pypi-simple
PyPI Simple Repository API client library
Stars: ✭ 21 (-92.42%)
Mutual labels:  pypi, pip
Matrixprofile Ts
A Python library for detecting patterns and anomalies in massive datasets using the Matrix Profile
Stars: ✭ 621 (+124.19%)
Mutual labels:  pypi, pip
Python Pixabay
Python 3 Pixabay's API wrapper.
Stars: ✭ 32 (-88.45%)
Mutual labels:  pypi, pip
pipx
Install and Run Python Applications in Isolated Environments
Stars: ✭ 5,698 (+1957.04%)
Mutual labels:  pypi, pip
rfc-bibtex
A command line tool that creates bibtex entries for IETF RFCs and Internet Drafts.
Stars: ✭ 43 (-84.48%)
Mutual labels:  pypi, pip
                   __
                  /\ \
 __  __    ___    \_\ \     __   _ __   ____    ___    ___   _ __    __      _____   __  __
/\ \/\ \ /' _ `\  /'_` \  /'__`\/\`'__\/',__\  /'___\ / __`\/\`'__\/'__`\   /\ '__`\/\ \/\ \
\ \ \_\ \/\ \/\ \/\ \_\ \/\  __/\ \ \//\__, `\/\ \__//\ \_\ \ \ \//\  __/  _\ \ \_\ \ \ \_\ \
 \ \____/\ \_\ \_\ \___,_\ \____\\ \_\\/\____/\ \____\ \____/\ \_\\ \____\/\_\ \ ,__/\/`____ \
  \/___/  \/_/\/_/\/__,_ /\/____/ \/_/ \/___/  \/____/\/___/  \/_/ \/____/\/_/\ \ \/  `/___/> \
                                                                               \ \_\     /\___/
                                                                                \/_/     \/__/

Underscore.py is a python port of excellent javascript library underscore.js

What is underscore.js?

From underscore page: Underscore.js is a utility-belt library for JavaScript that provides support for the
usual functional suspects (each, map, reduce, filter...) without extending any core JavaScript objects.

NOTE: It's obvious that python already has nearly all features of underscore library built-in. I'm not trying to fill any gap in python. If you are coming from JavaScript this library will provide you a familiar interface, a set of tools you already know how to use and micro templating functionality. Use it wisely and try to use built-in functions wherever possible.

Build Status

Installing

Install from pypi

pip install underscore.py

or

Clone the repository:

git clone git://github.com/serkanyersen/underscore.py.git

Get into underscore.py directory

cd underscore.py

Run setup script

sudo python setup.py install

That's it

Usage

Import underscore to your project

from underscore import _

or if you don't want to mess with _ variable

from underscore import _ as us  # You can use any name you want, __ or u

Use it just like javascript version

# Dynamically
_(["foo", "bar"]).invoke("upper")  # ["FOO", "BAR"]
# or statically
_.filter(["foo", "hello", "bar", "world"], lambda x, *a: len(x) > 3)  # ["hello", "world"]
# Do chaining
_([10, 48, 56, 30, 20]).chain().filter(lambda x, *a: x > 20).map(lambda x, *a: x * 2).sortBy().value()
# [60, 96, 112]

Full micro templating support

tmpl = _.template("Name: <% if prefix: %><%= prefix %>. <% endif %><%= name %>\n\
Last Name: <%=lname.upper() %>\n\
<% if email: %>\
E-mail: <%= email %>\n\
<% endif %>")

people = [{
  "prefix": "",
  "name": "John",
  "lname": "Doe",
  "email": "[email protected]"
},{
  "prefix": "Mr",
  "name": "James",
  "lname": "Brown",
  "email": "[email protected]"
}]

for person in people:
  print tmpl(person)

Output

Name: John
Last Name: DOE
E-mail: [email protected]
Name: Mr. James
Last Name: BROWN
E-mail: [email protected]

For more information and documentation underscorejs.org

Original Source: Underscore.js on Github

Disclaimer

Please keep in mind that this is a direct port of a javascript library, so don't get started with the "but it's not pythonic" stuff. This library has no intentions to be pythonic, infact it tries to bring the same underscore experience from javascript to python

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].