Catalog PyPI
PACKAGE EXPLORERView in registry

2us

PyPI

Glueing functionals with __.

Versions collected1
Direct dependencies0From release 0.0.1.post1
Last observed20 Oct, 15:27 UTC

README

Version 0.0.1.post1 documentation

__ (Double Underscores, 2us)

PyPI version

Glueing functionals by import __ for python!

Install

The package is written in pure python, with no dependencies other than the Python language. Just do:

pip install 2us

Requires Python 3.5 or higher.

Why this?

Python is a great language for creating convenient wrappers around native code and implementing simple, human-friendly functions. In python, a bunch of builtin higher-order methods (which means that they accept functions as arguments) such as map, filter are available. They enable streamed data processing on containers that focus on the processing itself, in contrast with noisy code on traditional command-based languages that is heavily involved in loops.

However, you may occasionally run into the situatiion where you find that there is no standard library functions to implement in-line unpacking of tuples, adding all numbers in a list by a constant shift, so you will have to write:

map(lambda x: x + 1, some_list)
map(lambda x: x[0], some_list)

which seems rather dumb due to the inconvenient definition of lambda functions in python.

Using __

Start using the package by importing __:

import __

And then __ can be used to create convenient functions that are identical to those written with lambda. Examples:

assert sum(map(__ + 1, range(1000))) == sum(map(lambda x: x + 1, range(1000)))
assert set(map(__[0], {1: 2, 4: 6}.items())) == {1, 4}
assert functools.reduce(__ + __, range(1000)) == sum(range(1000))

Currently there is a drawback: python do not support overriding __contains__ returning non-boolean values, so the in condition should be handled separately.

assert tuple(map(__.is_in([1, 2]), [3, 1, 5, 0, 2])) == (False, True, False, False, True)
assert list(map(__.contains('1'), '13')) == [True, False]

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Versions 1

Collected releases
VersionPublishedDirect dependenciesOpen version
0.0.1.post130 Oct 20200

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Repository

PENDING
strongrex2001/2us

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 15:27 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:37507822f6d128c9474da02eec461dbffe80a4de497153bde1c87e6382914b1c